Delete file in "changes not set for commit"

This is my git status:

# 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 delete one file at a time, is there any other way so that I can delete them at the same time?

+4
source share
2 answers

In this case, you could do

 git rm 'solr/data/development/index/_0.*' 

Pay attention to the ' labels to prevent shell expansion and instead pass * directly to git.

Here is 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 # 
+10
source

You can also use:

 git rm --cached `git status | grep deleted | sed 's#^.*:##'` 

All files listed in the deleted: prefix are deleted: in git status

+5
source

Source: https://habr.com/ru/post/1443742/


All Articles