Skip to content

Comparing trees in git

Leif Walsh edited this page Jul 17, 2013 · 1 revision

Note that a "tree" is a commit hash, branch name (e.g. master), or tag name, as well as some special names (e.g. HEAD) and positional references (e.g. HEAD~3 for "three commits behind HEAD").

Most git commands understand a special syntax tree1...tree2, which means "all commits on the branch containing and up to tree2, starting at the common ancestor of tree1 and tree2" (see git-diff(1)). Rigorously, it means "from $(git merge-base tree1 tree2) to tree2". With only two dots (tree1..tree2) it doesn't do anything special to find the common ancestor, so it's not quite as useful.

To see the log of commits on releases/1.0 since it diverged from master:

$ git log master...releases/1.0

You can see the same information at http://github.com/Tokutek/mongo/compare/master...releases/1.0.

To see the files that changed in that range:

$ git whatchanged master...releases/1.0

To see the combined diff of those changes:

$ git diff master...releases/1.0

To see a commit message and the diff for that commit:

$ git show abcd123

This also works on ranges, and it's like doing git show on every commit in the range.

Clone this wiki locally