+2 votes
1 view
in Devops and Agile by (28.1k 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:    cc.properties

#   deleted:    store/README

#   deleted:    store/cc.properties

#

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

2 Answers

+2 votes
by (48k points)

Try this command: 

git reset HEAD cc.properties

Which will unstage the rm command.

Then followed by a 

git status

Which shows what you need to do

git checkout -- cc.properties

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 (28.4k 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 (28.1k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...