1.一個(gè)新功能需求開發(fā)產(chǎn)生一個(gè)新的feature分支feature-some
git checkout -b feature-some develop
2.feature-some完成開發(fā)及測(cè)試
git add somefiles
git commit -m "message"
3.需要合并到develop分支-git merge
git checkout develop
git merge feature-some
git resolved conflicts
git add modfiy
git commit -m "message"
git push origin develop
這時(shí)使用git log會(huì)看到明顯的git merge信息,并不是自己寫的message
如果讓分支歷史看起來像沒有經(jīng)過任何合并一樣,你也許可以用 git rebase
4.需要合并到develop分支-git rebase
git checkout develop
git rebase feature-some
5.解決沖突
在rebase的過程中,也許會(huì)出現(xiàn)沖突(conflict). 在這種情況,Git會(huì)停止rebase并會(huì)讓你去解決 沖突;在解決完沖突后,用"git-add"命令去更新這些內(nèi)容的索引(index), 然后,你無需執(zhí)行 git-commit,只要執(zhí)行:
$git rebase--continue
這樣git會(huì)繼續(xù)應(yīng)用(apply)余下的補(bǔ)丁。
在任何時(shí)候,你可以用--abort參數(shù)來終止rebase的行動(dòng),并且"mywork" 分支會(huì)回到rebase開始前的狀態(tài)。
$git rebase--abort
參考: