« Back to Index

Git: Revision Range

View original Gist on GitHub

Tags: #git #revision #range

git revision range.md

Reference: https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection

Log commits in feature branch that aren’t in master:

git log master..feature

If you git pull your master branch you might find there are additional commits from your colleagues. So you might want to check what commits were recently merged into master that aren’t in your feature branch:

git log feature..master

The triple dot range will show you all the git commits that aren’t common to both branches.

Imagine we have a master branch with the commits A, B. We create the feature branch and add C, D commits. Then we go back to master and add E, F commits. In this scenario both branches have A, B commits, but diverge from there. The following log example will report C, D, E, F because these commits aren’t common to both branches:

git log master...feature