Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove file in 'changes not staged for commit`

Tags:

git

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 remove one by one file, is there another way so i can remove them same time?

like image 500
Thanh Avatar asked Dec 06 '22 11:12

Thanh


1 Answers

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.

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
#
like image 95
Peter Avatar answered Dec 11 '22 09:12

Peter