0

This is the case:

I've accidentally removed the .git folder in my project. How can I undo this that there are no consequences?

nielsv
  • 6,540
  • 35
  • 111
  • 215

1 Answers1

8

Clone it again.

If you have made un-pushed modifications, then clone it in another directory, move the .git to your original directory, and re-add the changes to the index.

If you were working on a branch different from master, then clone it in another directory, checkout to the branch, then move the .git to your original directory, and re-add the changes to the index.

To make sure you don't make another silly mistake, backup your directory before doing anything.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255