A Great Way to Simplify Git Merges

If you are struggling with a git merge with a long list of failed merge files then this little trick might be helpful.

The standard approach is to go file by file and use git mergetool to open the files in a tool like Meld and then manually manage the differences. In many cases though you know exactly which version you want and this is simply a laborious process that doesn’t really require human input.

The solution to this is deceptively simple. All you need to do is to check out the file from the branch you want to keep the version of. If you have an entire directory where you know that the branch (for example master) has the correct version then you can check out that entire directory.

You might find that sensible use of this technique can save you lots of time and really make the mergetool the one you use for the files where you really do need to merge.

Thanks to this StackOverflow answer for simplifying this for me.


Tags: checkoutgitmergemeldmergetoolbranch