標籤:style class blog code http tar
gerrit是不會解決衝突的,如果兩個人同時改了一個檔案的同一行,就會衝突,你將會看到Review in Progress並且最下面會有Your change could not be merged due to a path conflict.
如果在衝突提交者機器上解決遠程衝突
cd demogit fetch origingit rebase origin/develop修改衝突檔案git add .git rebase --continuegit push origin不會產生新的changes記錄,將原changes記錄重新review提交即可git pull
如果在其它機器上解決遠程衝突
cd demo以分支為develop為例開啟Gerrit有衝突的那個網址,如 http://192.168.1.33:8080/#/c/16/ 找到Download 如下命令,執行git fetch ssh://[email protected]:29418/demo refs/changes/16/16/1 && git checkout FETCH_HEADgit checkout -b new_branch_namegit fetch origingit rebase origin/develop修改衝突檔案git add .git rebase --continuegit push origin new_branch_name:refs/for/developgit checkout developgit branch -D new_branch_name不會產生新的changes記錄,將原changes記錄重新review提交即可,這時在原衝突機器上直接pull會本地衝突,需要git reset --hard HEAD^否則會出現cannot do a partial commit during a merge.最後更新下代碼git pull
擴充閱讀:撤銷前一次 commitgit revert HEAD 撤銷所有本地修改git reset --hard撤銷所有本地到上一次修改git reset --hard HEAD^
1.Gerrit裡點擊“publish and submit”提示如下:
Your change could not be merged due to a path conflict.
Please merge (or rebase) the change locally and upload the resolution for review.
2.解決方案如下:
cd ~/projects/pan #切換到pan項目 git branch #查看分支情況 git checkout master #選擇分支 git fetch origin #fetch與pull的區別,自己再搜吧~ git rebase origin/master #查看有“CONFLICT (content): ”的地方,手工解決衝突後,下一步 git add dev/controller/web/index.php #這隻是一個舉例,即要先add操作 git rebase --continue git push origin HEAD:refs/for/master #OK了
git push後,你需要在Gerrit裡面再次review一次。
3.本文參考部落格:《Git,Gerrit,hudson(3)--git技巧總結》
雖然對git還是有些疑惑,anyway,衝突的問題還是解決了。
參考:http://johnshen0708.iteye.com/blog/1487760
http://rubyist.marsz.tw/blog/2012-01-17/git-reset-and-revert-to-rollback-commit/