M.O.R.R.I.S. M.O.R.R.I.S. - 1 month ago 18
Git Question

Restore deleted .git folder from GitHub

I have continued working with GitHub Visual Studio extension and accidentally deleted

.git
folder from my local repository.
Is there a way to download
.git
folder from GitHub to my repository?

Answer

If you accidentally deleted a .git folder in your local working copy, and want to restore it from remote repository (e.g. on GitHub), then the following should work (assuming that you are in the root directory where you want to put .git folder):

git init
git remote add origin <url>
git fetch
git reset origin/master

Here <url> is the URL of the remote repository (for instance, git@github.com:git/git.git or https://github.com/git/git.git).

Comments