Removed files after git rm -r -f . command git rm -r -f . .

How to restore them now? it was the first commit, before that there was not a single commit, we just locally made git add . therefore, the project was not poured into the repository and it will not be possible to restore it from there.

 $ git reflog fatal: your current branch 'master' does not have any commits yet 

Reported as a duplicate member Nick Volynkin 10 Nov '16 at 7:43 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • Judging by the reflog, there were no commits yet. But if exactly there was git add . , use the instructions in the answer link above. - Nick Volynkin
  • Well, how did it help? - Nick Volynkin

1 answer 1

Good morning! If you delete the first local commit, try

 git reflog 

there will be a list of all commits (including deleted ones), something like this

 1a410ef HEAD@{0}: 1a410efbd13591db07496601ebc7a059dd55cfe9: updating HEAD 1a410ef HEAD@{0}: 1a410efbd13591db07496601ebc7a059dd55cfe9: updating HEAD 1a410ef HEAD@{0}: 1a410efbd13591db07496601ebc7a059dd55cfe9: updating HEAD 

take the commit number from there and

 git reset --hard номерКоммита 

PROFIT !!!

  • one
    $ git reflog fatal: your current branch 'master' doesn’t have any commits yet received such an error, we simply didn’t have a single commit before that, we just made git add locally. after they realized that all the files were gone they added git ignore after they wanted to delete the commit but all the files were deleted with it) - Samat Yeshernkulov
  • If there is no commit and there is no remote repository, then git will not restore anything here. He just about your project and then does not know anything. I hope you did not have much time to do it. - Mikl
  • there is some inconsistency. Was it a commit or not? Anyway, what's in the .git/objects folder? - KoVadim