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

4

1 回答 1

4

管道弄乱了别名。!git您可以通过添加到别名的开头来做您想做的事情。

尝试:

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

请注意,我将您的"引号替换'为以阻止!扩展。

在您的 git 配置中,您现在应该具有以下内容:

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

从技术上讲,!意味着“按原样在 shell 中运行”,所以这就是为什么需要git在命令行开头添加的原因。很酷的一点!是,如果你愿意,你可以用 git 以外的东西开始一个别名。

于 2013-11-03T03:05:47.763 回答