git 删除“未暂存以进行提交的更改”中的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13203008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove file in 'changes not staged for commit`
提问by Thanh
This is my git status:
这是我的 git 状态:
# On branch create-views-question
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: solr/data/development/index/_0.fdt
# deleted: solr/data/development/index/_0.fdx
# deleted: solr/data/development/index/_0.fnm
# deleted: solr/data/development/index/_0.frq
...
Currently, i used git rm
to remove one by one file, is there another way so i can remove them same time?
目前,我曾经git rm
一个一个地删除文件,有没有其他方法可以同时删除它们?
回答by Peter
In this case you could do
在这种情况下,你可以做
git rm 'solr/data/development/index/_0.*'
Note the '
marks to prevent shell expansion and instead pass the *
directly to git.
请注意'
防止外壳扩展的标记,而是将*
直接传递给 git。
Here's an example:
下面是一个例子:
graphite> git status
# On branch master
# Changes not staged for commit:
# deleted: a
# deleted: b
#
no changes added to commit
graphite> git rm '*'
rm 'a'
rm 'b'
graphite> git status
# On branch master
# Changes to be committed:
# deleted: a
# deleted: b
#
回答by test30
You can also use:
您还可以使用:
git rm --cached `git status | grep deleted | sed 's#^.*:##'`
This removed all files listed with deleted:
prefix in git status
这删除了所有带有deleted:
前缀的文件git status