Git lists branch names with unset commits

Given a project with several local branches, each of which tracks the remote branch, is there a command that lists all the branches that did not unlock transactions? (That is, even if none of these branches are checked.)

I don’t want to see the commits themselves and don’t want to see the branches that are relevant, I just want to see which branches are ahead of my remotes.

I tried git log --branches --not --remotes --simplify-by-decoration --decorate --oneline , but it doesn't seem to show what I need. Running this in my current repo does not work, but running git status in 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 display both updated branches and those that need to be pressed. However, they both show my current branch as [ahead 2] .

Other teams that I found, for example. git log @{u}.. , git cherry -v specify the commit itself, not the branch.

Side question: why is the output from git log --branches --not --remotes --simplify-by-decoration --decorate --oneline not including the branches that git branch -v shows ahead? Not the first team, just looking at which refs/heads does not match the well-known console; so that the industry indicated as [ahead 2] meet these criteria?

+12
git branch
Aug 30 '16 at 7:02
source share
2 answers

The --no-walk option for log seems to do a better job of what I need than --simplify-by-decoration . My complete command:

git log --branches --not --remotes --no-walk --decorate --oneline

... which I changed to unpushed .

+2
Jan 10 '18 at 5:34
source share
 git for-each-ref --format="%(refname:short) %(push:track)" refs/heads 

This remains the most accurate answer to the fact that you can easily parse / grep to get the desired result (for example, removing actual branches)

You can do this in a bash script that you will name git-xxx (without extension), somewhere in $PATH or %PATH% .
Then the script can be called using git xxx and will use git bash.
This is portable and will work on different platforms (which means even on Windows, where <Git For Windows>/usr/bin includes 200+ Linux commands ( grep , sed , awk , xargs , ...)

+7
Aug 31 '16 at 8:04
source share



All Articles