Question

I want to create a sh script that configures all my git aliases. Some of the aliases have pipes (|) and doublequotes ("). The output I want to see in my ~/.gitconfig file is:

[alias]
    assume = update-index --assume-unchanged
    unassume = update-index --no-assume-unchanged
    assumed = "!git ls-files -v | grep ^h | cut -c 3-"

However, running the following three commands yields an incorrect assumed entry:

# setup git aliases per: http://blog.apiaxle.com/post/handy-git-tips-to-stop-you-getting-fired/
git config --global alias.assume "update-index --assume-unchanged"
git config --global alias.unassume "update-index --no-assume-unchanged"
git config --global alias.assumed '"!git ls-files -v | grep ^h | cut -c 3-"'

The third alias (assumed) has undesired backslashes:

assumed = \"!git ls-files -v | grep ^h | cut -c 3-\"

What is the correct syntax to configure the alias via command line?

Était-ce utile?

La solution

You don't need double quotes in .gitconfig.

So the command is:

git config --global alias.assumed '!git ls-files -v | grep ^h | cut -c 3-'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top