如何在 git-for-each-ref 中使用 –stdin 选项?

huangapple go评论74阅读模式
英文:

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

我想要做的是获取与不同命令给出的模式匹配的所有分支。举个例子,假设我想获取所有在 alphabeta 中的本地引用。我写了以下命令:

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 &#39;refs/heads/alpha/**\nrefs/heads/beta/**&#39; | git for-each-ref &#39;refs/heads/**&#39; --stdin

but it failed. I also tried writing it like:

git for-each-ref &#39;refs/heads/**&#39; --stdin &lt;&lt;&lt; &#39;refs/heads/alpha/**\nrefs/heads/beta/**&#39;

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.

huangapple
  • 本文由 发表于 2023年6月30日 02:49:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583869.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定