Last active
December 22, 2015 00:49
-
-
Save taq/6392286 to your computer and use it in GitHub Desktop.
Git ahead/Behind numbers in the prompt - Copied from http://blogs.atlassian.com/2013/07/git-upstreams-forks/?utm_source=2013-08-newsletter&utm_medium=email&utm_campaign=atlassian-newsletter
This file contains 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
# Use it like `export PS1="\h:\w[\$(ahead_behind)]$"` | |
function ahead_behind { | |
curr_branch=$(git rev-parse --abbrev-ref HEAD); | |
curr_remote=$(git config branch.$curr_branch.remote); | |
curr_merge_branch=$(git config branch.$curr_branch.merge | cut -d / -f 3); | |
git rev-list --left-right --count $curr_branch...$curr_remote/$curr_merge_branch | tr -s '\t' '|'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment