gpt4 book ai didi

--no-merged 而不是 --contains 的 git 分支标志?

转载 作者:太空狗 更新时间:2023-10-29 14:05:12 25 4
gpt4 key购买 nike

git branch --contains master 返回其提示 master 可到达的分支的名称。

git branch --merged master 返回其提示可从 master 到达的分支的名称。

git branch --no-merged master 返回提示无法从 master 访问的分支的名称。

是什么标志(可能在较新版本的 git 中?)显示分支的名称,这些分支的提示既不能从 master 访问,也不能访问 主人在他们自己的祖先?换句话说,什么标志给出了 --no-merged --no-contains 的效果?

换句话说,如何显示既不能快进 merge 到master又不能从master快进 merge 的分支?

最佳答案

2017 年 4 月更新,正如我在“How to list all git branches containing a commit”中提到的,选项 --no-containsnow supported with Git 2.13 .

原始答案

What is the flag (perhaps in a newer version of git?)

首先,您提到的 --(no-)merged 标志已被概括为 ref-filter fairly recently (git 2.7, Sept. 2015) .

--no-contains

快速搜索显示此选项不存在(在 git 存储库的任何分支中:

MINGW64 ~/git/git (master)
$ git branch -a | tr -d \*|grep -v origin|xargs git grep --break --heading --line-number 'no\-contain'

因此您需要编写脚本,列出所有未被 --contains 选择的分支(但在 --no-merged 中列出)。

"git tag/branch/for-each-ref" family of commands long allowed to filter the refs by:

  • "--contains X" (show only the refs that are descendants of X),
  • "--merged X" (show only the refs that are ancestors of X),
  • "--no-merged X" (show only the refs that are not ancestors of X).

One curious omission, "--no-contains X" (show only the refs that are not descendants of X) has been added to them.

关于--no-merged 而不是 --contains 的 git 分支标志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36032688/

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