I have two branches: branch_1
and branch_2
.
How can I see the differences between them?
You want to use git diff.
git diff [<options>] <commit>..<commit> [--] [<path>…]
Where <commit>
is your branch name, the hash of a commit or a shorthand symbolic reference
For instance git diff abc123..def567
or 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>
And if you just want 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