命令:git hist 错误。致命:选项“--graph”必须出现在非选项参数之前

问题描述 投票:0回答:2

我尝试在 GitBash、Windows 上运行 git hist cmd,但收到以下错误

fatal: option '--graph' must come before non-option arguments

在窗口 PowerShell 上,我输入:

git config --global alias.hist log --pretty=format: '%h %ad | %s%d [%an]' --graph --date= short"

但仍然遇到同样的错误。
请我知道为什么以及如何避免这个错误?

cmd gitlab alias git-bash git-config
2个回答
2
投票

只需先移动

--graph
/
--date
选项即可。

我刚刚通过常规 CMD 进行了测试(不需要 PowerShell):

git config --global alias.hist "log --graph --date=short --pretty=format:'%h %ad | %s%d [%an]'"

然后 git hist 就可以正常工作了。

注意

format:
'%h...'

之间缺少空格

0
投票

对我来说这也解决了问题。谢

删除格式后的空格为我解决了这个错误。我在最后留下了图表和日期选项。 – 穆里 2023 年 6 月 7 日 20:11

© www.soinside.com 2019 - 2024. All rights reserved.