dole doug dole doug - 6 months ago 34
Git Question

How to test a merge without actually merging first

Is there any way of simulating a

git merge
between two branches, the current working branch and the master, but without making any changes?

I often have conflicts when I have to make a
git merge
. Is there any way of simulating the merge first?

Answer Source

I don't think there is a way of simulating what will happen until you try the merge. However, if you make sure that the output of git status is empty before you do the merge, it is quite safe to just go ahead and try it. If you get conflicts, you can immediately get back to the state you were at before with:

git reset --merge

Since git 1.7.4, you can also abort the merge by doing:

git merge --abort

(As the commit message that added that option explains, this was added for consistency with git rebase --abort and so on.)