将git状态的结果管道化为后续命令

时间:2012-07-10 18:36:19

标签: linux git bash pipe

我的Git存储库中有大量活动文件。我做的一个改变是删除了许多目录中的大量图像。我想立即提交更改,但我不想包含所有活动文件,我不想为每个图像手动输出git rm myfile.png

基本上我想要做的就是以git rm结尾的所有活动文件运行.png。我试图通过将git status的结果汇总到git rm来实现这一点,但是我无法隔离文件名并让它按照我的意愿运行。

这是管道的正确使用吗?如果是,我需要什么语法?

感谢任何帮助,谢谢。

1 个答案:

答案 0 :(得分:1)

如果您已删除文件,则可以输入:

git add -u

它们将从git存储库中删除。

来自git help add

-u, --update
           Only match <filepattern> against already tracked files in the index
           rather than the working tree. That means that it will never stage
           new files, but that it will stage modified new contents of tracked
           files and that it will remove files from the index if the
           corresponding files in the working tree have been removed.