How to delete files in batches using git rm
怪我咯
怪我咯 2017-05-02 09:45:35
0
2
612
git rm -f *.json.gz
fatal: pathspec '01eece012a88a1a7077de645f44bbb71baf67cae.json.gz' did not match any files

git rm *.gz
fatal: pathspec '01eece012a88a1a7077de645f44bbb71baf67cae.json.gz' did not match any files


git rm *.*.gz
fatal: pathspec '01eece012a88a1a7077de645f44bbb71baf67cae.json.gz' did not match any files
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
刘奇

Using git rm进行批量删除其实和rm命令是一样的,都支持通配符。只是楼主没有正确理解git rm的适用场合。git rm适用于那些你要删除的文件已加入暂存区,而楼主的这些文件并未加入暂存区就使用git rm,而git rm will search for those files in the temporary storage area, but these files are not in the temporary storage area. At this time, of course, an error "No matching file" will be reported.

So for files that have not been added to the temporary storage area, you can use the regular deletion method. It is not necessary to use git rm;而对于已经加入暂存区的文件使用git rm which is a more reasonable deletion method.

I think the poster may not have grasped the root cause of the error, and mistakenly thought that git rm不能像rm also supports wildcards.

習慣沉默

/q/10...
git add -A

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template