Thanh
Thanh

Reputation: 8604

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

Upvotes: 4

Views: 14883

Answers (3)

Pytth
Pytth

Reputation: 4176

Personally, if I just want my local to look like remote, I like to do:

git reset --hard upstream/BRANCHNAME

Upvotes: 0

test30
test30

Reputation: 3654

You can also use:

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

This removed all files listed with deleted: prefix in git status

Upvotes: 6

Peter
Peter

Reputation: 132227

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
#

Upvotes: 9

Related Questions