Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
show git ahead/behind info for branches
moved to github --> https://github.com/bill-auger/git-branch-status/
Copy link

ghost commented Nov 29, 2012

try to run
git remote update
prior to running the script, this will sync your local repo to the remote one

@bergerjac
Copy link

bergerjac commented Feb 5, 2013

save having to parse the output...
instead of: git rev-list --left-right {local}...{remote}; use:
git rev-list {local}..{remote} --count
git rev-list {remote}..{local} --count

@hilbix
Copy link

hilbix commented Nov 29, 2013

@kd35a
Copy link

kd35a commented Dec 12, 2013

If anyone is interested, I've added a status-line at the end if everything is synchronized. Which is quite nice if you also have a morning routine of doing git fetch --all && git-branch-status.

See: https://gist.github.com/kd35a/7924799

Edit: I'm having problems with basic arithmetics in bash, what the? Well, don't use my code for the time being.

@tschulte
Copy link

tschulte commented Feb 7, 2014

git branch -v | grep -E 'ahead|behind' | sed -r 's/[ *]\s(\S*).*(\[(ahead|behind).+?\]).*/\1 \2/g' does nearly the same. Using git branch -vv one could also get the upstream branch name.

@knovoselic
Copy link

knovoselic commented Oct 4, 2014

If anyone is interested, I've fixed kd35a's version of the script + added colors:

https://gist.github.com/knovoselic/1a20dc28dbb0141fc176

@bill-auger
Copy link

bill-auger commented Oct 31, 2014

if anyone interested - i found this script too - and i liked it - and i prettified it :)

building on @knovoselic version:

  • prettified into columns with adjustable max wdith
  • added ability to filter by branch name and to show locals
  • removed the temp file i/o - runs fully in memory
  • added command-line switches and usage message

my fork is here

@joeytwiddle
Copy link

joeytwiddle commented Jan 8, 2015

What a great script! 😍 Like you guys, I added colours and columns, and an indication of whether this branch has been merged into master, but I will admit my version is somewhat convoluted.

However, if you are only interested in the _current_ branch, then perhaps you would prefer to see ahead/behind counts on your prompt.

Git Branch in Prompt

@bill-auger
Copy link

bill-auger commented Mar 6, 2015

have add some features today

  • added '*' indicator near current branch
  • added dates of the last commit beside each branch and upstream

pull from my fork for the latest version

hopefully we can soon get this coordinated into a proper project

below is a screenshot of the latest version

alt text

@bill-auger
Copy link

bill-auger commented May 28, 2016

i have created a repo for this script on github in order to have a proper issue tracker - all further development and communications will take place there - feel free to clone, fork, star , or watch the github repo -->

https://github.com/bill-auger/git-branch-status/

this script is also now icluded in jwiegley's git-scripts collection but please direct comments, bug reports, and feature requests to the upstream issue tracker

@jehiah -
could you please merge my fork into yours - this will replace the script body with a link to the latest upstream repo on github like so:

git remote add bill-auger-gist https://gist.github.com/9335fe2633eae38d3070.git
git fetch bill-auger-gist
git merge bill-auger-gist/master

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