In git merge conflicts, how do I keep the version that is being merged in?

試著忘記壹切 提交于 2019-12-01 03:24:54

Even though you are using Git Tower, you can drop down to the command line and use

git checkout --theirs file.txt

Here some docs about it:

http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html

If you want to ONLY use git tower, complete the merge as is, then checkout the other branch's version of that file. Now stage and commit with amend - if possible.

Git has been developed to be a command line tool. With every other tooling that I've ever used, I always had a gap in functionality. I chose to embrace instead of fight the design of Git.

Also, you could hook up something like Beyond Compare and choose "external tool" as is mentioned in your question. There, you will have an option to choose the "theirs" side.

If you're looking to keep v2 hands down (I want master to look exactly like v2), I think the easiest way is to:

  • Checkout the branch you want to merge
  • Merge master into the branch with the ours strategy
  • Checkout master
  • Merge the branch

It would look like this:

git checkout v2
git merge -s ours master
git checkout master
git merge v2

If you just want this type of resolution to happen only on conflicts, then you can do:

git checkout master
git merge -s recursive -Xtheirs v2

You can read up on merge strategies in the git documentation here.

UPDATE: unfortunately, I don't think Git Tower exposes a way to do this yet. :-(

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!