Home > database >  How to init git folder and fetch the old commit from github?
How to init git folder and fetch the old commit from github?

Time:11-21

So I accidentally erased my .git folder from my project and after that made numerous changes to the files. How do I go about adding the git repository now?

As it has uncommitted files, I tried git init, setting the remote to origin, and executing git fetch and pull, but it failed.

I tried stashing, but it says You do not have the initial commit yet.

CodePudding user response:

You can easily salvage your repo by cloning to a different directory first, then copying over .git into your existing working tree. Now git status and git diff should show you your uncommitted changes again.

  •  Tags:  
  • git
  • Related