我已經寫了一些代碼,然後推送給主。在我需要重新推送一段時間之後(我已經爲同一個文件添加了更多代碼),我有太多的衝突,因爲在我第一次推我的代碼時,我的代碼被別人拉了,他用resharper來美化代碼並推送再次。所以現在我已經與我的修改文件和美化代碼合併衝突。 我需要做的是從主人拉代碼,然後用我的代碼覆蓋美化的代碼,並將其推送給主人。 我在窗戶上。使用git bash。git與遠程衝突,需要保持本地更改
1
A
回答
1
您可以backup your current branch for safety
然後pull master
並使用theirs/ours
解決衝突的文件。
$ git pull origin master
$ git status # copy the conflicted file name
$ git checkout --theirs -- . # accept remote changes if conflicts
or,
$ git checkout --ours -- . # accept local changes if conflicts
或者,
$ git reset --hard HEAD
$ git branch backup # backup your branch for safety
$ git pull origin master -s recursive -X theirs # accept remote master changes if conflicts
Or,
$ git pull origin master -s recursive -X ours # accept local changes if conflicts
0
如果您確定只有美化修改並且沒有內容更改,只需在衝突解決期間使用git checkout --ours -- path/to/your/file
即可完全取得您的文件版本。
相關問題
- 1. Git合併衝突 - 遠程文件已刪除,本地文件已更改
- 2. Git與本地設置:更改分支衝突
- 3. 更改git衝突標記
- 4. Git:如何結帳有衝突的文件的遠程更改
- 5. 從Git遠程撥號時使用遠程更改來解決衝突
- 6. git衝突保持原始上游
- 7. Git stash保持索引衝突
- 8. 確保git遠程跟蹤分支與遠端保持同步
- 9. 與遠程同步本地git回購一次拋棄本地更改/提交
- 10. 本地和遠程分支需要匹配git push的名稱?
- 11. 保持WordPress(本地和遠程)同步
- 12. 如何將遠程Git回購添加到本地回購並保持更新?
- 13. Git分支管理:本地與遠程
- 14. git:與遠程同步本地回購
- 15. 當本地沒有更改時,git工作副本如何衝突?
- 16. Git子樹合併,但保持本地更改?
- 17. git pull保留本地更改
- 18. Git:無法更改遠程
- 19. Git與程序集DLL文件衝突
- 20. Git - 對文件進行本地更改,但是,需要從遠程存儲庫獲取原始副本?
- 21. Git - 將更改從本地分支推送到遠程分支
- 22. Git狀態顯示遠程和本地更改
- 23. 在遠程提交和推送時放棄本地git更改
- 24. 如何在git上更改本地遠程分支
- 25. 用PHP頭衝突需要
- 26. 需要從本地調試eclipse插件更改爲遠程調試vm
- 27. Rails與引導遠程模式的遠程衝突
- 28. ScrollTo與Mousewheel.js衝突,需要更具體的事件?
- 29. 突然不能創建本地/遠程git分支
- 30. 需要幫助與jParallax衝突的腳本