-->

How can I recover files after accidentally running

2019-01-28 16:28发布

问题:

I have accidentally run git clean -df. It removed my files from my current commit, which I had yet to push. Now, in git status, those files are marked with D, which means "deleted".

Is there any way to get those files back?

回答1:

git clean only untracked files and not committed ones.

You might have done other operations if you see D as the status for already committed files.

You get back those files, do:

git checkout .

or

git reset --hard