I have a repository with multiple remotes. When I issue a git branch --all --verbose
it shows:
bar 9876de11 hello world
foo 12abde23 description
master 34fd4545 tony the pony
quz ab34df67 me, too
remotes/origin/bar 9876de11 hello world
remotes/origin/foo 12abde23 description
remotes/origin/master 34fd4545 tony the pony
remotes/origin/quz ab34df67 me, too
remotes/zulu/bar 9876de11 hello world
remotes/zulu/foo 12abde23 description
remotes/zulu/master 34fd4545 tony the pony
remotes/zulu/quz ab34df67 me, too
In this output it's hard to see, if every local branch is on par with its remote counterparts. I'd fancy an output ordered by local branch name:
bar 9876de11 hello world
remotes/origin/bar 9876de11 hello world
remotes/zulu/bar 9876de11 hello world
foo 12abde23 description
remotes/origin/foo 12abde23 description
remotes/zulu/foo 12abde23 description
master 34fd4545 tony the pony
remotes/origin/master 34fd4545 tony the pony
remotes/zulu/master 34fd4545 tony the pony
quz ab34df67 me, too
remotes/origin/quz ab34df67 me, too
remotes/zulu/quz ab34df67 me, too
This way, skimming over the output to see unpushed changes would be much easier on the eye. A naive solution
git branch -a -v | sort -t / -k 3
doesn't work, because the local entries have no "/" in them for sort
to look for.
This might be a little rough, but try this:
Basically, we extract the
basename
of the branch, giving us only the branchname without theremotes/origin/whatever
. We then sort by it, then cut it off of the final output viacut
. This can be tweaked and cleaned up, but it should give you a starting point. You can also add--color
to the initialgit branch
to preserve the colored output you'd see without pipinggit
to anything.