Explore Courses Blog Tutorials Interview Questions
+2 votes
in DevOps and Agile by (29.3k points)
edited by

I deleted some files.

I did NOT commit yet.

I want to reset my workspace to recover the files.

I did a git checkout.

But the deleted files are still missing.

And git status shows:

# On branch master

# Changes to be committed:

#   (use "git reset HEAD <file>..." to unstage)


#   deleted:

#   deleted:    store/README

#   deleted:    store/


Why doesn't git checkout? reset the workspace to HEAD?

2 Answers

+2 votes
by (50.2k points)

Try this command: 

git reset HEAD

Which will unstage the rm command.

Then followed by a 

git status

Which shows what you need to do

git checkout --

This command will get the file back

Or you can give this in your config file

git config alias.unstage

reset HEAD

This will unstage the file.

+1 vote
by (27.5k points)

Here git ls-files is used to checkout deleted(-d) or modified(-m) files.

$ git checkout $(git ls-files -d)

Related questions

0 votes
1 answer
asked Jul 13, 2019 in DevOps and Agile by chandra (29.3k points)
0 votes
1 answer

Browse Categories