背景:SourceTree使用過程中,用自己的郵箱提交了公司的項(xiàng)目大诸,發(fā)現(xiàn)push失敗十厢。
公司GitLab推送的時(shí)候會(huì)檢查郵箱是否屬于公司郵箱,所以需要修改自己郵箱為公司郵箱
變基探橱,是一連串命令的組合申屹。
參考:https://zhuanlan.zhihu.com/p/65561851,這個(gè)寫的很詳細(xì)隧膏,還包含了過程中sourcetree的界面哗讥,但是有一點(diǎn) 是不正確的,所以這里會(huì)糾正一下胞枕;
git rebase -i
執(zhí)行后杆煞,會(huì)打開最近一條的提交記錄
git rebase -i [startpoint] [endpoint]
其中-i
的意思是--interactive
,即彈出交互式的界面讓用戶編輯完成合并操作腐泻,[startpoint] [endpoint]
則指定了一個(gè)編輯區(qū)間索绪,如果不指定[endpoint],則該區(qū)間的終點(diǎn)默認(rèn)是當(dāng)前分支HEAD所指向的commit(注:該區(qū)間指定的是一個(gè)前開后閉的區(qū)間)贫悄。
假設(shè)需要修改最近兩次提交的郵箱:
git rebase -i e0585da
如果以第二條commit ID作為startpoint 只會(huì)得到最新的一次提交記錄瑞驱,因?yàn)閰^(qū)間是前開。
That means after(>) startpoint, so what's the right way?
git rebase -i cffb707
or git rebase -i cffb707 ba419e9
rebas之后會(huì)出現(xiàn)一個(gè)文件窄坦,其實(shí)就是類似Linux文件唤反。
將pick
修改為edit
,然后:wq
You can amend the commit now, with
?
git commit --amend
?
Once you are satisfied with your changes, run
?
git rebase --continue
chengmingdeMacBook-Pro:server cmlanche$
接下來:git commit --amend --author="xiaosi <xiaosi@alibaba.com>"
注意:姓名與郵箱之間有一個(gè)空格鸭津,之前看博客說需要空格彤侍,待驗(yàn)證
最后:git rebase --continue
總結(jié)三步:
1.git rebase -i
2.git commit --amend --author="xiaosi <xiaosi@alibaba.com>"
3.git rebase --continue