I want to create an alias in git git cleanIgnore but I can not figure out how to pipe the output from command 1 to command 2.
I'm using PowerShell and the following command works great from the prompt
git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}
and I defined this in my global config like this, it doesn't work
[alias]
cleanIgnore = "!git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}"
cleanIgnore2= "!git ls-files -i --exclude-from=.gitignore "
I can get the first half to work as an alias, but I keep getting an error on usage when i do git cleanIgnore
git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}: %{git: command not found
fatal: While expanding alias 'cleanignore': 'git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}': No such file or directory
It seems that the ! isn't just passing everything to the shell to execute, but is doing something more still
update/answer
[alias]
cleanIgnore = "!powershell.exe -command 'git ls-files -i --exclude-from=.gitignore | %{git rm --cached $_}'"