linux - 将 git status 的结果通过管道传递给后续命令

标签 linux git bash pipe

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

基本上我想做的是对所有以 .png 结尾的事件文件运行 git rm。我试图通过将 git status 的结果传送到 git rm 中来实现这一点,但我在隔离文件名并使其正常工作时遇到了问题喜欢。

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

感谢任何帮助,谢谢。

最佳答案

如果您已经删除了这些文件,您可以键入:

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.

关于linux - 将 git status 的结果通过管道传递给后续命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11419698/

相关文章:

git - 使用 Git Flow,成功的分支模型

linux - 返回当前 UTC 时间字符串的 Bash 函数回显它和 CWD 以及原始文件名

linux - awk 子串单个字符

c++ - cc (C++) 中 -h <name> 和 -o <outputfile> 选项的区别

android - 我在编译android源码的时候有一些疑问

python - 如何使用 gitPython 将 'pipe' 密码发送到 remote.update()

bash - ZSH:在脚本文件中执行函数

linux - 将文件从一个目录递归复制到另一个目录会导致一个目录中的更改也会反射(reflect)在另一个目录文件中吗?

linux - 在 Ubuntu 3.13.0-163-generic 上构建 GRPC 编译失败

git - 将 git 设置为仅忽略根文件夹中的 index.php 而不是子文件夹中的所有 index.php 文件