根据我的搜索,以下 2 个命令应该为我提供带有作者姓名的远程分支。然而,我没有得到任何回报——你知道为什么吗?
我正在使用 Windows 命令提示符。
下面的命令返回:“输入文件指定了两次。”
git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n
Run Code Online (Sandbox Code Playgroud)
以下命令不返回任何内容:
git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)'
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能列出所有带有作者姓名的活动分支?
A.H*_*.H. 16
您正在尝试在 Windows cmdshell 中运行 Unix-Command 。Windowssort不理解-k5n语法。尝试在bashGit For Windows 提供的shell 中运行它,它不会打印错误。
不过还有改进的余地:git for-each-ref可以自行排序:
git for-each-ref --sort=committerdate --format='%(committerdate) %09 %(authorname) %09 %(refname)'
Run Code Online (Sandbox Code Playgroud)
下一篇:你提到你只想要远程分支。实际上,您还会获得本地分支、标签、注释以及其他一些东西。您可以将其限制为远程分支:
git for-each-ref --sort=committerdate --format='%(committerdate) %09 %(authorname) %09 %(refname)' refs/remotes
Run Code Online (Sandbox Code Playgroud)
由于不再有sort命令,您可以cmd在调整format参数的引用后再次运行它(cmd并bash使用不同的引用语义):
git for-each-ref --sort=committerdate --format="%(committerdate) %09 %(authorname) %09 %(refname)" refs/remotes
Run Code Online (Sandbox Code Playgroud)