I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I?
In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability to see the list of commits that are being applied.
So far, the best I can come up with is
merge --no-ff --no-commit, and then
git log ..otherbranch
- list of changes that will be merged into current branch.
git diff ...otherbranch
- diff from common ancestor (merge base) to the head of what will be merged. Note the three dots, which have a special meaning compared to two dots (see below).
- graphical representation of the branches since they were merged last time.
Empty string implies
HEAD, so that's why just
..otherbranch instead of
The two vs. three dots have slightly different meaning for diff than for the commands that list revisions (log, gitk etc.). For log and others two dots (
a..b) means everything that is in
b but not
a and three dots (
a...b) means everything that is in only one of
b. But diff works with two revisions and there the simpler case represented by two dots (
a..b) is simple difference from
b and three dots (
a...b) mean difference between common ancestor and
git diff $(git merge-base a b)..b).