windowsgitcmdaliasgit-untracked

Git aliasing truncates command definition


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?


Solution

  • 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.