gpt4 book ai didi

git - 在 Git 中,列出具有未推送提交的分支名称

转载 作者:IT王子 更新时间:2023-10-29 00:51:59 24 4
gpt4 key购买 nike

给定一个有多个本地分支的项目,每个分支都跟踪一些远程分支,是否有一个命令列出所有未推送提交的分支? (也就是说,即使没有 check out 这些分支。)

我不想看到提交本身,也不想看到最新的分支,我只想看看哪些分支在它们的远程之前。

我试过 git log --branches --not --remotes --simplify-by-decoration --decorate --oneline,但它似乎没有显示我需要的东西。在我当前的 repo 上运行它没有输出,但是在我当前的分支上运行 git status 显示 Your branch is ahead of 'origin/branchname' by 2 commits.

git for-each-ref --format="%(refname:short) %(push:track)"refs/headsgit branch -v 两者显示最新的分支以及需要推送的分支。但是,它们确实都将我当前的分支显示为[ahead 2]

我发现的其他命令,例如。 git log @{u}.., git cherry -v 列出提交本身,而不是分支。

附带问题:为什么 git log --branches --not --remotes --simplify-by-decoration --decorate --oneline 的输出不是包括 git branch -v 前面显示的分支?前一个命令不只是查看哪些 refs/heads 不对应于已知的 Remote 吗?那么列为 [ahead 2] 的分支是否满足此条件?

最佳答案

log--no-walk 选项似乎比 --simplify-by-decoration。我的完整命令是:

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

...我将其命名为 unpushed

关于git - 在 Git 中,列出具有未推送提交的分支名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39220870/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com