Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIt Config Alias With Quotes and Pipes via Command Line

Tags:

git

git-config

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?

like image 222
JJ Zabkar Avatar asked Feb 13 '14 17:02

JJ Zabkar


1 Answers

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-'
like image 87
Alexey Ten Avatar answered Sep 21 '22 20:09

Alexey Ten