Comparing branches

At some point, we'll have to merge our branches to master. To get a list of the commits that will be merged into the master branch when we do so, we use

git log master..branch_name

With this, Git will give us a list of all the commits that are in the other branch, but not in master. Just as before, we can use the --oneline option to make the output more concise.

Comparing branches 1
Comparing branches 2

If want to see the actual changes we use the diff command

git diff master..branch_name

Here Git will show us the diff of the different files that will be affected by the merge.


When diffing branches we don't always have to type both branches. If we want to see the diff between the branch we are currently in and another branch we just run

git diff branch_name

If we only want a list of the files that will change and the type of change, we can use the --name-status option

git diff --name-status branch_name