< pattern>的格式是什么?在git-branch --list [英] What is the format of <pattern> in git-branch --list

查看:161
本文介绍了< pattern>的格式是什么?在git-branch --list的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为标题,我已经阅读了该手册但徒劳.

As title, I have read the manual but in vain.

我发现*可以是通配符模式匹配.

What I found is that a * can be wildcard pattern matching.

git branch --list 'issues*6'
 issues/586
 issues/616

但是,它是我自己找到的,而不是在手册页中提到的.

However, it's found by myself instead of mentioned in manual page.

我想知道<pattern>的真正格式是什么.

I wonder what is the real format of <pattern>.

推荐答案

引用相同的

如果给出了--list,或者没有非选项参数,则列出现有分支;否则,将列出现有分支.当前分支将以星号突出显示.选项-r导致列出远程跟踪分支,选项-a同时显示本地和远程分支. 如果给出了<pattern>,则用作外壳通配符,以将输出限制为匹配的分支.如果给出了多个模式,则显示与任何模式匹配的分支.请注意,在提供<pattern>时,必须使用--list.否则,该命令将被解释为分支创建.

If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches. If a <pattern> is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns. Note that when providing a <pattern>, you must use --list; otherwise the command is interpreted as branch creation.

因此,至少根据文档,答案是它用作外壳通配符".当然,这是假定您知道短语"shell通配符"的含义-更重要的是,这是错误,因为在/上,直壳通配符将不匹配.

So the answer, at least according to the documentation, is that "it is used as a shell wildcard". This assumes, of course, that you know what the phrase "shell wildcard" means—and more importantly, it's wrong, since a straight shell wildcard would not match across the /.

文档应该说:该模式的行为与shell通配符/glob模式非常相似,不同之处在于,不对斜杠进行特殊处理,因此a*baccbac/cb以及a[bc/]*都匹配.匹配所有a/dabcdac/cbaccb."

The documentation should say something like: "The pattern acts much like a shell wildcard / glob pattern, except that slashes are not treated specially, so that a*b matches both accb and ac/cb, and a[bc/]* matches all of a/d, abcd, ac/cb, and accb."

示例:

$ git branch -a
  a/d
  abcd
  ac/cb
  accb
* master
$ git branch --list 'a*b'
  ac/cb
  accb
$ git branch --list 'a[bc/]*'
  a/d
  abcd
  ac/cb
  accb
$ 

这篇关于&lt; pattern&gt;的格式是什么?在git-branch --list的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆