How do I see the differences between two branches?

Use git diff.

git diff [<options>] <commit>..​<commit> [--] [<path>…​]

<commit> is a branch name, a commit hash, or a shorthand symbolic reference.

Examples: git diff abc123..def567, git diff HEAD..origin/master.

That will produce the diff between the tips of the two branches. If you’d prefer to find the diff from their common ancestor to test, you can use three dots instead of two:

git diff <commit>...<commit>

To check which files differ, not how the content differs, use --name-only:

git diff --name-only <commit>..​<commit>

Note that in the <commit>..<commit> (two dot) syntax, the dots are optional; the following is synonymous:

git diff commit1 commit2

Leave a Comment