Jed B
Jed B

Reputation: 43

Accidentally deleted .git folder in Git's install directory

I forgot to $ cd prior to deleting a .git directory and I happened to be inside Git's main folder, located on my hard drive at /usr/local/git.

I figured there's no need for a .git folder in this directory. However, just to be safe, I did a $ sudo git init so the folder would be there if Git was looking for it.

Did I bork anything? Does Git even use this folder? Should I restore from the old clone instead?

Thanks!

Upvotes: 0

Views: 829

Answers (1)

manojlds
manojlds

Reputation: 301337

Update - On re-reading the question, I realize you are not talking about a repository that you had intentionally created. The question doesn't seem to make sense. If there was .git at /usr/local/git, it might have been created accidentally while cloning or init of some repo etc. But then you say you had a 3 week old clone of it, which doesn't make sense. Anyway, if it is the former case, you need not worry. There shouldn't have been a .git there and git doesn't make use of it.


Does Git even use this folder - this is all that Git uses, because it is your repo. Unless you have clones of your repo elsewhere or have backed up your repo, you have lost your changes. Your 3 week old clone will let you recover some stuff, but any history that you had since then will be lost. Assuming you did not delete your working directory, you can still have your changes, but the history will be lost ( including any branches you had created in the 3 weeks etc.)

Upvotes: 1

Related Questions