Cause:
在Gerrit等待code review通過期間,若有協同開發者先merge commit,且該commit和自己的commit
發生衝突的情況
Solution:
1.
在發生conflict
的 branch上
執行
git pull --rebase origin master
此指令說明如下
This
command will fetch new commits from the remote and then rebase your
local commits on top of them. It will temporarily set aside the
changes you've made in your branch, apply all of the changes that
have happend in master to your working branch, then merge (recommit)
all of the changes you've made back into the branch. Doing this will
help avoid future merge conflicts. Plus, it gives you an opportunity
to test your changes against the latest code in master.
Once
you are satisfied with your change set and you've rebased against
master, you are ready to push your code to Gerrit for review.
簡單的說:把master上已合併的commit(但在目前branch不存在),接到目前的branch上,再把
目前branch的commit接到最後面(最新)
當然在Gerrit網頁上合併會發生衝突,所以執行這個指令之後在本地端也會發生衝突,把執行後的提示紀錄下來如下
When
you have resolved this problem run "git rebase --continue".
If
you would prefer to skip this patch, instead run "git rebase
--skip".
To
check out the original branch and stop rebasing run "git rebase
–abort".
第一行為當修改衝突後,要執行的指令
2.修改發生衝突的地方,使用vim修改
3.把修改後的檔案全部
git
add
4.git
add 所有的檔案之後執行 git
rebase --continue
5.最後
git
push origin HEAD:refs/for/master
6.必須重新等待code
review