简体   繁体   English

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

[英]git branch flag for --no-merged and not --contains?

git branch --contains master returns the names of branches from whose tips master is reachable. git branch --contains master返回其提示master可达的分支的名称。

git branch --merged master returns the names of branches whose tips are reachable from master . git branch --merged master返回其提示可从master访问的分支的名称。

git branch --no-merged master returns the names of branches whose tips aren't reachable from master . git branch --no-merged master返回其提示无法从master访问的分支的名称。

What is the flag (perhaps in a newer version of git ?) to show the names of branches whose tips are neither reachable from master , nor can reach master in their own ancestry?什么是标志(也许在新版本的git ?),以显示其分支提示从没有到达的名字master ,也可以达到master在自己的祖先? In other words, what flag gives the effect of --no-merged --no-contains ?换句话说,什么标志给出了--no-merged --no-contains

To put it another way, how to show branches which could not have a fast forward merge into master nor have a fast forward merge from master into them?换句话说,如何显示既不能快进合并到 master 也不能从 master 快进合并到它们的分支?

Update April 2017 , as I mentioned in " How to list all git branches containing a commit ", the option --no-contains is now supported with Git 2.13 . 2017 年 4 月更新,正如我在“如何列出包含提交的所有 git 分支”中提到的, 现在 Git 2.13 支持选项--no-contains

Original Answer原答案

What is the flag (perhaps in a newer version of git?)标志是什么(也许在较新版本的 git 中?)

First, the --(no-)merged flags you mention have been generalized as ref-filter fairly recently (git 2.7, Sept. 2015) .首先,您提到的--(no-)merged标志最近被概括为 ref-filter (git 2.7, Sept. 2015)

--no-contains

A quick search reveals this option does not exist (in any of the branches of the git repo:快速搜索显示此选项不存在(在 git repo 的任何分支中:

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

So you would need to script that, listing all branches which are not selected by --contains (but are listed in --no-merged ).因此,您需要编写脚本,列出所有未由--contains选择的--contains (但在--no-merged中列出)。

" git tag/branch/for-each-ref " family of commands long allowed to filter the refs by: git tag/branch/for-each-ref ”系列命令长期以来允许通过以下方式过滤参考:

  • " --contains X " (show only the refs that are descendants of X ), --contains X ”(仅显示作为X后代的引用),
  • " --merged X " (show only the refs that are ancestors of X ), --merged X ”(仅显示作为X祖先的引用),
  • " --no-merged X " (show only the refs that are not ancestors of X ). --no-merged X ”(仅显示不是X祖先的引用)。

One curious omission, " --no-contains X " (show only the refs that are not descendants of X ) has been added to them.一个奇怪的遗漏,“-- --no-contains X ”(只显示不是X后代的引用)已添加到它们中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM