在Git中,列出具有未完成提交的分支的名称 [英] In Git, list names of branches with unpushed commits
问题描述
我不想看到提交本身,也不希望看到分支是最新的,我只想看看哪些分支领先于他们的遥控器。
我试过 git log --branches - 不是--remotes --simplify-by-decoration --decorate --oneline
,但它似乎并不显示我需要的东西。在我当前的回购库上运行它不会产生输出,但在当前分支上运行 git status
会显示您的分支比'origin / branchname'提前2提交。
git for-each-ref --format =%(refname:short)%(push :track)refs / heads
和 git branch -v
都显示最新的分支以及需要推送的分支。然而,他们 do 都显示我当前的分支为 [ahead 2]
。
其他命令我已经找到例如。 git log @ {u} ..
, git cherry -v
列出提交自身,而不是分支。 p>
支持问题:为什么会输出 git log --branches --not --remotes --simplify-by -decoration --decorate --oneline
不包括分支 git branch -v
显示为提前?是不是前面的命令只是查看哪个 refs / heads
不对应于已知的远程;所以不会有一个分支被列为 [ahead 2]
满足这个标准吗?
- no-walk
选项至 log
似乎比我所需要的要好得多 - 简化逐装饰
。我的完整命令是:
git log --branches --not --remotes --no-walk --decorate --oneline code>
...这是我的别名 unpushed
。
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?
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
.
这篇关于在Git中,列出具有未完成提交的分支的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!