Git aliasing truncates command definition

48 Views Asked by At

I have been trying to alias the following command for removing tracked files from the repository:

> git config --system alias.untrack 'rm --cached'

However when I check the configuration, the alias definition is truncated and throws when used:

> git config --list
alias.untrack='rm
> git untrack
fatal: bad alias.untrack string: unclosed quote

How to avoid the above behaviour?

1

There are 1 best solutions below

1
ElpieKay On BEST ANSWER

I guess you ran the command in Windows CMD. If so, use double quotes instead of single quotes.

git config --system alias.untrack "rm --cached"

On Windows, git bash is recommended over CMD or PowerShell. With the latter 2, you have to deal with some annoying special characters.