Git merge strategies

Here are a few comments about Git merge strategies.

When you do something like git merge FETCH_HEAD, Git will by default apply a recursive strategy when you pull or merge one branch.

I had a case where I had to pull in commits from a "similar but unrelated" Git repository. I did a git fetch to grab the changes into a local FETCH_HEAD. But when I did git merge with the default merge strategy, the merge failed miserably (lots of conflicts).

When I tried the resolve strategy, the merge failed totally :
$ git merge -s resolve FETCH_HEAD

But when I tried the following, the merge worked as desired :
$ git merge -s subtree FETCH_HEAD

Remember, if your merge doesn't go as planned, you can do this to rollback everything to your original HEAD :

$ git reset --hard HEAD

http://www.kernel.org/pub/software/scm/git/docs/git-merge.html
http://www.kernel.org/pub/software/scm/git/docs/git-reset.html

Categories: