Git RM几个文件? [英] Git rm several files?

查看:116
本文介绍了Git RM几个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何轻松删除多个文件,而无需手动输入全部路径至 git rm ?我有很多修改过的文件,我想保留,所以删除所有的修改也是不可能的。



还可以在不手动的情况下还原几个文件的更改键入 git checkout - / path / to / file

解决方案

你可以给通配符 git rm



例如

  git rm * .c 

或者您可以写下一个文件中所有文件的名称,比如 filesToRemove.txt

  path / to / file.c 
path / to / another / file2.c
path / to / some / other / file3.c

您可以自动执行此操作:

  find。 -name'* .c'> filesToRemove.txt 

打开文件并查看名称(确保它没有问题)。



然后:

  cat filesToRemove.txt | xargs git rm 

或者:

<$ p $对于`cat filesToRemove.txt`中的我来说,

;做git rm $ i;完成

查看 xargs 的手册页以获取更多信息选项(尤其是如果文件太多)。


How do I easily remove several files without manually typing the full paths of all of them to git rm? I have plenty of modified files I'd like to keep so removing all modified is not possible either.

And also it is possible to revert the changes of several files without manually typing git checkout -- /path/to/file?

解决方案

You can give wildcards to git rm.

e.g.

git rm *.c

Or you can just write down the names of all the files in another file, say filesToRemove.txt:

path/to/file.c
path/to/another/file2.c
path/to/some/other/file3.c

You can automate this:

find . -name '*.c' > filesToRemove.txt

Open the file and review the names (to make sure it's alright).

Then:

cat filesToRemove.txt | xargs git rm

Or:

for i in `cat filesToRemove.txt`; do git rm $i; done

Check the manpage for xargs for more options (esp. if it's too many files).

这篇关于Git RM几个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆