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