J86
J86

Reputation: 15237

Git alias on Windows: How to escape double quotes

I am on a Windows 10 Pro Machine and I am using Cmder with Git version 2.15.0.windows.1.

I want to set up an alias for the git log command with some pretty options. The command is:

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

When I try to set the alias up by running this command:

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

It does not work, the alias is not registered. I suspect it is because I have double quotes within the command too.

I also tried wrapping it with single quotes ', but that does not work either.

How can I escape those double quotes within the command so that the alias does register?

Upvotes: 4

Views: 1225

Answers (1)

Ashish Mathew
Ashish Mathew

Reputation: 823

Use single quotes for the pretty=format string.

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

Upvotes: 6

Related Questions