gpt4 book ai didi

windows - Windows 上的 Git 别名 : How to escape double quotes

转载 作者:可可西里 更新时间:2023-11-01 09:22:51 25 4
gpt4 key购买 nike

我在 Windows 10 专业版机器上使用 Cmder使用 Git 版本 2.15.0.windows.1

我想为 git log 命令设置一个带有一些漂亮选项的别名。命令是:

log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --decorate

当我尝试通过运行此命令来设置别名时:

git config --global alias.ls "log --pretty=format:"%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]" --decorate"

它不起作用,别名未注册。我怀疑这是因为我在命令中也有双引号。

我也试过用单引号'把它包起来,但这也不管用。

如何在命令中转义那些双引号以便别名注册?

最佳答案

对 pretty=format 字符串使用单引号。

git config --global alias.ls "log --pretty=format:'%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]' --decorate"

关于windows - Windows 上的 Git 别名 : How to escape double quotes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47631492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com