Skip to content

Instantly share code, notes, and snippets.

@hugooliveirad
Last active August 29, 2015 13:55
Show Gist options
  • Save hugooliveirad/8788821 to your computer and use it in GitHub Desktop.
Save hugooliveirad/8788821 to your computer and use it in GitHub Desktop.
Git ahead and behind info
# add this function to your .bash_profile to be able to use it everywhere
# usage: git-ahead-behind [local-branch] [remote-branch]
function git-ahead-behind() {
branch="`git symbolic-ref --short -q HEAD`";
loc="${1-$branch}";
remote="${2-origin/$loc}";
git fetch $remote &> /dev/null
wait
out="ahead: `git rev-list $remote..$loc --count`";
out="$out\nbehind: `git rev-list $loc..$remote --count`";
echo $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment