git for-each-ref with <pattern> returns 什么都没有
git for-each-ref with <pattern> returns nothing
git branch --list 'hotfix' returns 包含单词的分支列表'hotfix' 在分支名称中,而
git for-each-ref --format='%(authorname)' 'hotfix' return 没什么,甚至 /n 符号
正如 git for-each-ref
的 the document 所说,
If one or more patterns are given, only refs are shown that match
against at least one pattern, either using fnmatch(3) or literally, in
the latter case matching completely or from the beginning up to a
slash.
正如 fnmatch
的 the document 所说,
The fnmatch() function checks whether the string argument matches the
pattern argument, which is a shell wildcard pattern (see glob(7)).
分枝如路refs/heads/foo/bar
,这里的模式应该是refs/heads/**/*hotfix*
,
git for-each-ref --format='%(authorname)' 'refs/heads/**/*hotfix*'
如果你也想要远程分支,
git for-each-ref --format='%(authorname)' 'refs/heads/**/*hotfix*' 'refs/remotes/**/*hotfix*'
2 个模式匹配 hotfix
、origin/hotfix-118
、hotfix-118
、118-hotfix
、my-hotfix-110
、
等分支
git branch
仅查看(默认情况下)分支 - refs/heads
中的引用 - 因此它允许您使用仅匹配 "branch name" 的模式(例如 some-hotfix
这实际上是 shorthand 完整的参考名称 refs/heads/some-hotfix
).
for-each-ref
正在查看所有 refs,因此它不允许您使用此类模式。如果您知道自己只对分支感兴趣,则可以使用 refs/heads/*hotfix*
之类的东西(如果不感兴趣,则可以使用 **/*hotfix*
之类的东西)。
git branch --list 'hotfix' returns 包含单词的分支列表'hotfix' 在分支名称中,而 git for-each-ref --format='%(authorname)' 'hotfix' return 没什么,甚至 /n 符号
正如 git for-each-ref
的 the document 所说,
If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the beginning up to a slash.
正如 fnmatch
的 the document 所说,
The fnmatch() function checks whether the string argument matches the pattern argument, which is a shell wildcard pattern (see glob(7)).
分枝如路refs/heads/foo/bar
,这里的模式应该是refs/heads/**/*hotfix*
,
git for-each-ref --format='%(authorname)' 'refs/heads/**/*hotfix*'
如果你也想要远程分支,
git for-each-ref --format='%(authorname)' 'refs/heads/**/*hotfix*' 'refs/remotes/**/*hotfix*'
2 个模式匹配 hotfix
、origin/hotfix-118
、hotfix-118
、118-hotfix
、my-hotfix-110
、
git branch
仅查看(默认情况下)分支 - refs/heads
中的引用 - 因此它允许您使用仅匹配 "branch name" 的模式(例如 some-hotfix
这实际上是 shorthand 完整的参考名称 refs/heads/some-hotfix
).
for-each-ref
正在查看所有 refs,因此它不允许您使用此类模式。如果您知道自己只对分支感兴趣,则可以使用 refs/heads/*hotfix*
之类的东西(如果不感兴趣,则可以使用 **/*hotfix*
之类的东西)。