M.O.R.R.I.S. M.O.R.R.I.S. - 8 months ago 70
Git Question

Restore deleted .git folder from GitHub

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

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


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).