Tag Archives: git_branches

Git diff between branches

There are several ways of displaying the differences between your git branches. The most direct one is:

$ git diff [branchA]..[branchB]

However, this will display the code difference as if it was a single big commit. If the diff is big enough, or if you want to see a list os just the commits, this way is not very helpful. But thre are some tweaks we can make. The one I’ve been using mostly in the past weeks is:

$ git log --oneline --graph --all --decorate

Well, like always, when I see too big a command like this, I create an alias for it.
Anyway, this command will print the current layout of all branches of your project, including the remote ones.

For example:


It produces a cool graph layout with the commit title only, and it’s a very useful way to understand where things are in your project. However, if it’s really a big project, it might be too overwhelming.

I created some new branches with new commits and got a little more elaborated tree, like this:


For the graph above, I created a new branch “bug883” from “develop” and “sample_branch” from “master”. None of them was pushed remotely, as we can tell by the output. From this point on, it’s just interpretation of your project. You should be able to understand the differences between the branches of your project.

Well, give it a try and share what you think.

UPDATE: Many other ways of getting the diffs are discussed in this Stack Overflow post.

You may also would like to see what branches were not merged to master.