Lucia
Lucia

Reputation: 1

How can I recover files after running "git clean -df" by accident?

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?

I have tried the following:

git checkout . and git reset --hard

and I get the following message:

git checkout .

fatal: Unable to create '/Users/lucia/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.

❯ git reset --hard fatal: Unable to create '/Users/lucia/.git/index.lock': File exists.

Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.**

If I follow this path '/Users/lucia/.git/index.lock' on my computer, it doesn't exist.

Upvotes: 0

Views: 2950

Answers (0)

Related Questions