Skip to content

Instantly share code, notes, and snippets.

@GrayedFox
Last active February 5, 2024 03:40
Show Gist options
  • Save GrayedFox/2b6229e25650afaba6ceabcd4b1ba7de to your computer and use it in GitHub Desktop.
Save GrayedFox/2b6229e25650afaba6ceabcd4b1ba7de to your computer and use it in GitHub Desktop.
Count how many unique commits are on your current branch
#!/usr/bin/env bash
BRANCH="main"
if [ $# -eq 1 ] ; then
BRANCH=$1
fi
# count how many commits on your branch are not on the target branch, defaults to main
git rev-list HEAD --count ^$BRANCH
@GrayedFox
Copy link
Author

GrayedFox commented Dec 2, 2018

Updated to count only unique commits (read: commits not on main/master)

@GrayedFox
Copy link
Author

GrayedFox commented Jun 21, 2021

Updated to accept a single argument in case main is not the default branch (i.e. git count master)

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