Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git alias on Windows: How to escape double quotes

Tags:

git

windows

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?

like image 409
J86 Avatar asked Oct 16 '25 15:10

J86


1 Answers

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"
like image 103
Ashish Mathew Avatar answered Oct 18 '25 08:10

Ashish Mathew