git 衝突解決(轉載)

來源:互聯網
上載者:User

標籤: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/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.