Given a project with several local branches, each tracking some remote branch, is there a command that lists all branches that have unpushed commits? (That is, even if none of t
although the answers above are very helpful and show alot of data but for others coming here looking for a solution to find local branches which are ahead i.e. have not been pushed yet. can get the exact list by executing:
git branch -v | grep ahead
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
.
You can also see what branches are not yet merged to master
git checkout master
and then
git branch --no-merged
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
, ...)