我试图显示所有当前的分支,同时应用关于我想要使用--格式的字段的标准。
当我只显示一个字段时,它正在工作,但只要包含多个字段,它就什么也不返回。
例如,此操作(返回日期):
λ git for-each-ref --format='%(committerdate)' --sort=committerdate
'Tue Aug 10 15:32:14 2021 +0200'
'Thu Sep 30 09:35:57 2021 +0000'
'Fri Oct 22 09:54:05 2021 +0000'
'Tue Nov 16 09:58:55 2021 +0000'
'Tue Jul 19 12:20:46 2022 +0000'
'Wed Sep 14 09:55:06 2022 +0000'
'Wed Sep 14 09:55:06 2022 +0000'
'Wed Sep 14 09:55:06 2022 +0000'
'Wed Sep 14 09:55:06 2022 +0000'
'Wed Sep 21 06:35:24 2022 +0000'
'Tue Sep 27 05:44:38 2022 +0000'
'Tue Sep 27 07:59:01 2022 +0000'
'Tue Sep 27 07:59:01 2022 +0000'这也同样有效(返回分支名称):
λ git for-each-ref --format='%(refname)' --sort=committerdate
'refs/tags/1.0.0'
'refs/tags/1.0.1'
'refs/tags/1.0.2'
'refs/tags/1.1.0'
'refs/tags/1.2.0'
'refs/heads/develop'
'refs/heads/master'
'refs/remotes/origin/HEAD'
'refs/remotes/origin/master'
'refs/remotes/origin/develop'
'refs/remotes/origin/bugfix/RPA0075-1363'
'refs/heads/release/1.3.0'
'refs/remotes/origin/release/1.3.0'但是,只要我想要这两个字段,它就什么也不返回:
λ git for-each-ref --format='%(committerdate) %(refname)' --sort=committerdate对我做错了什么有什么想法吗?
发布于 2022-09-27 12:14:41
这个问题与Windows有关。'在cmd.exe中不是字符串分隔符,而是常规单词的一部分。
git for-each-ref --format='%(committerdate) %(refname)' --sort=committerdate被解析为:
git for-each-ref --format="'%(committerdate)" --sort=committerdate " %(refname)'"由于没有名为%(refname)'的分支,所以输出将为空。要修复,切换到带有合理引用规则的shell (例如,Git for Windows附带Git Bash (显然运行Bash))或使用双引号:
git for-each-ref --format="%(committerdate) %(refname)" --sort=committerdatehttps://stackoverflow.com/questions/73866603
复制相似问题