Skip to content

Instantly share code, notes, and snippets.

@nils-werner
Created December 8, 2011 12:51
Show Gist options
  • Save nils-werner/1446914 to your computer and use it in GitHub Desktop.
Save nils-werner/1446914 to your computer and use it in GitHub Desktop.
Git Alias for displaying number of commits between two branches
[alias]
between = !sh -c 'echo $1 $(git log --pretty=oneline ${2}..$1 | wc -l) ahead && echo ${2:-$(git name-rev --name-only HEAD)} $(git log --pretty=oneline $1..$2 | wc -l) ahead' -
@nils-werner
Copy link
Author

This works exactly as GitHubs "branches" feature. For example:

  1. Compare master to integration

     $ git between master integration
     integration 288 ahead
     master 5 ahead
    
  2. Compare current branch to integration

     $ git between integration
     integration 288 ahead
     templates 5 ahead
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment