Brent Keller

Comparing branches

It can be useful to compare two branches to see how they differ. You can even compare a branch to its branch commit to see what work has been done in that branch.

# Compare the head of each branch
# (all changes in both branches)
git diff branch1..branch2

# Compare the head of branch2 to the common ancestor of the branches
# (work done in branch2)
git diff branch1...branch2

I found this article to be really helpful in explaining and visualizing the differences in the commands: How To Compare Two Git Branches

There's also the git documentation for reference too.

© 2023 Brent Keller