How to prefer files from one branch during a merge?

后端 未结 1 1231
北荒
北荒 2021-02-03 21:01

Some time ago I created a branch from my master branch. Let\'s call it new_feature. While I was working on new_feature, the master

1条回答
  •  深忆病人
    2021-02-03 21:31

    As mention in the comment there are several strategies in the documentation. You can also find them here: http://git-scm.com/docs/git-merge

    You are looking for either git merge -s recursive -X ours or git merge -s recursive -X theirs depending on the branch that you are on. Be careful with these as you can accidentally miss changes to your files from the other branch and these would be overwritten.

    Another method, which I prefer due to more control, is to git checkout -- . This way I don't accidentally overwrite a file with the wrong changes.

    0 讨论(0)
提交回复
热议问题