In Git, list names of branches with unpushed commits
git for-each-ref --format="%(refname:short) %(push:track)" refs/heads
That remain the most precise answer that you can easily parse/grep to get the desired output (like removing up-to-date branches)
You can do so in a bash script that you will call git-xxx
(no extension), somewhere in your $PATH
or %PATH%
.
That script can then be called with git xxx
, and will use git bash.
That is portable and will work across platforms (meaning even on Windows, where <Git For Windows>/usr/bin
includes 200+ linux commands (grep
, sed
, awk
, xargs
, ...)
You can also see what branches are not yet merged to master
git checkout master
and then
git branch --no-merged
The --no-walk
option to log
seems to do a better job of what I need than --simplify-by-decoration
. My full command is:
git log --branches --not --remotes --no-walk --decorate --oneline
...which I've aliased to unpushed
.