2017-01-18 46 views
1

我已經寫了一些代碼,然後推送給主。在我需要重新推送一段時間之後(我已經爲同一個文件添加了更多代碼),我有太多的衝突,因爲在我第一次推我的代碼時,我的代碼被別人拉了,他用resharper來美化代碼並推送再次。所以現在我已經與我的修改文件和美化代碼合併衝突。 我需要做的是從主人拉代碼,然後用我的代碼覆蓋美化的代碼,並將其推送給主人。 我在窗戶上。使用git bash。git與遠程衝突,需要保持本地更改

回答

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即可完全取得您的文件版本。