Last active
August 29, 2015 13:55
-
-
Save hugooliveirad/8788821 to your computer and use it in GitHub Desktop.
Git ahead and behind info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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