2

I have a problem adding an alias to my git config for this set of commands.

git ls-files --deleted -z | xargs -0 git rm

I tried this:

git config --global alias.rmd "ls-files --deleted -z | xargs -0 git rm"

When I run git rmd this would prompt me with a missing parameter for ls-files. Is the alias syntax incorrect or perhaps there is a typo somewhere ... ?

1 Answer 1

4

The pipe is messing up the alias. You can do what you want by adding !git to the beginning of your alias.

Try:

git config --global alias.rmd '!git ls-files --deleted -z | xargs -0 git rm'

Note that I replaced your " quotes with ' to stop the ! from being expanded.

In your git config, you should now have the following:

[alias]
    rmd = !git ls-files --deleted -z | xargs -0 git rm

Technically, ! means "run in the shell as-is", so you that's why you need to add git at the beginning of your command line. The cool thing about ! is you can start an alias with something other than git if you like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.