英文:
How can I use the --stdin option with git-for-each-ref?
问题
最近,自从 git 2.41.0 版本开始,为 for-each-ref
命令添加了一个 --stdin
选项。我尝试使用它来筛选只有特定引用,但失败了,反而得到了以下错误信息:
fatal: unknown arguments supplied with --stdin
我想要做的是获取与不同命令给出的模式匹配的所有分支。举个例子,假设我想获取所有在 alpha
或 beta
中的本地引用。我写了以下命令:
echo 'refs/heads/alpha/**\nrefs/heads/beta/**' | git for-each-ref 'refs/heads/**' --stdin
但是失败了。我还尝试过这样写:
git for-each-ref 'refs/heads/**' --stdin <<< 'refs/heads/alpha/**\nrefs/heads/beta/**'
但是得到了相同的错误。
截至今天(2023年6月29日),文档中没有展示如何使用 --stdin
的示例。
英文:
Recently, since git 2.41.0, a --stdin
option has been added for the for-each-ref
command. I tried using it to filter only certain refs but I failed and got this error message instead:
fatal: unknown arguments supplied with --stdin
What I wanted to do was to get all the branches that match a pattern given by a different command. For argument’s sake let's say that I want to get all local refs that are in alpha
or beta
. I was writing:
echo 'refs/heads/alpha/**\nrefs/heads/beta/**' | git for-each-ref 'refs/heads/**' --stdin
but it failed. I also tried writing it like:
git for-each-ref 'refs/heads/**' --stdin <<< 'refs/heads/alpha/**\nrefs/heads/beta/**'
but got the same error.
As of today (29/06/2023) there aren't any examples in the docs showing how to use --stdin
答案1
得分: 2
"synopsis for git-for-each-ref" 说
git for-each-ref … [ --stdin | <pattern>… ]
这意味着您需要提供要么 --stdin
要么一个模式。您当前提供了两者。删除 refs/heads/**
参数,只使用 --stdin
。
英文:
The synopsis for git-for-each-ref says
> ```
> git for-each-ref … [ --stdin | <pattern>… ]
which means you need to provide either --stdin
or a pattern. You are currently providing both. Remove the refs/heads/**
argument and only use --stdin
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论