Re: Show all branches and ahead/behind states
- From
Dennis Kaarsemaker <dennis@kaarsemaker.net>
- Date
- May 14, 2015, 17:29 UTC
- Message-ID
- <1431624587.31573.5.camel@kaarsemaker.net>
- In-Reply-To
- <CAHd499CQTW0J6ms+XYUBbyfT6gGKuiFFCiP57i8-eTwng+UzNQ@mail.gmail.com>
On do, 2015-05-14 at 12:18 -0500, Robert Dailey wrote:
Show 22 quoted lines
> On Thu, May 14, 2015 at 10:55 AM, Dennis Kaarsemaker > <dennis@kaarsemaker.net> wrote: > > On do, 2015-05-14 at 09:57 -0500, Robert Dailey wrote: > >> Is there a script or built-in functionality in git 2.4.1 that will > >> allow me to list all local branches with the ahead and behind status > >> of each? Basically the first line of: > >> > >> $ git status -sb > >> > >> But for every branch would be roughly what I'm looking for. Any ideas? Thanks. > > > > git branch -v (or -vv) is what you're after. > > -- > > Dennis Kaarsemaker > > www.kaarsemaker.net > > > > Nice, I never noticed that -v showed ahead/behind status. Would be > nice if branch had a --format option to customize the coloring of the > "ahead" / "behind" text so that there was more contrast. It's a lot of > information to consume especially with a lot of local branches; > coloring would bring some sanity.
Fortunately for you, git for-each-ref lets you do just this. For example, this gives you what branch -vv does, minus coloration and padding:
git for-each-ref --format '%(HEAD) %(refname:short) %(upstream:short) %(upstream:track) %(subject)' refs/heads
-- Dennis Kaarsemaker www.kaarsemaker.net