Smokie Smokie - 5 months ago 33
Git Question

Review the result of git-merge before the actual merge

Is there a way to review the result of a merge between two branches before actually merging them ?

When attempting to merge branch A to branch B, I usually checkout a temporary branch from B, merge it with branch A, then I'd create a diff patch, or just checkout to that temporary branch and check whether everything is working fine before merging A to B.

Does git provide a command or a feature that would accomplishes this?


As Marian Theisen suggested, you can do this to do the merge without committing

git merge --no-commit <branchname>

You can back out of that merge with

git reset --hard

Also, remember that it is always easy to back up in Git. You can do a full merge, including commit, inspect the complete result and if you change your mind you can

git reset --hard HEAD^

to throw away the merge and be back at the commit before the merge.

In fact, at any point during the merge resolution, you can do

git reset --merge

To abort the merge and throw away just the merge changes.