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 those branches are checked out.)
I don't want to see the commits themselves, nor do I want to see branches that are up-to-date, I just want to see which branches are ahead of their remotes.
I have tried git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
, but it doesn't seem to show what I need. Running it on my current repo gives no output, but running git status
on my current branch shows Your branch is ahead of 'origin/branchname' by 2 commits.
git for-each-ref --format="%(refname:short) %(push:track)" refs/heads
and git branch -v
both show branches that are up to date as well as ones that need pushing. However, they do both show my current branch as [ahead 2]
.
Other commands I have found eg. git log @{u}..
, git cherry -v
list the commits themselves, not the branches.
Side question: why would the output from git log --branches --not --remotes --simplify-by-decoration --decorate --oneline
not include branches that git branch -v
shows as ahead? Isn't the former command just looking at which refs/heads
do not correspond to a known remote; so wouldn't a branch listed as [ahead 2]
meet this criteria?