0

I don't know if this is the best place to ask it, but I have a serious problem.

I've worked 3 months on a project. And planned to go to GIT.

I did a git init, a month back. A few days after the init I've renamed the project.

After that I accidentally did these commands.

git rm * -r -f - Because some 'deletes' weren't staged for commit
git reset --hard - Because I thought I was able to reset to before the git rm.

I didn't know that git was able to remove files and haven't committed anything.

Am I able to get my files back, and how?

kostix
  • 51,517
  • 14
  • 93
  • 176
user3489690
  • 21
  • 1
  • 3

3 Answers3

2

Thanks to @torek and Recover dangling blobs in git. I've got my files back!

I did a git fsck --lost-found and all my files were in .git/lost-found/other

I've created a new xcode project and after one hour of work, everything is working again!

Community
  • 1
  • 1
user3489690
  • 21
  • 1
  • 3
1

Since you never committed anything, the files are gone.

You can confirm this using git reflog and verifying that no commits were ever made.

The reflog for an empty repository looks like this:

$ git reflog
fatal: bad default revision 'HEAD'

as opposed to a repository with a single commit:

$ git reflog
a1b2c3d HEAD@{0}: commit (initial): Initial commit
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
1

If you're using an IDE like Eclipse that has a local history, you can try that (restore from local history). If you had something like a maven build that also generated a sources jar, then you can try it as well.

Otherwise, sorry your files are gone. Next time: commit early, commit often.

ptyx
  • 4,074
  • 1
  • 19
  • 21