Reputation: 81
If I have a Git account on, say, GitHub, and previously I have set up the local repository, have committed and pushed several times.
Now I have carelessly deleted the local repository (.git), but the remote repository is still there in GitHub, how can I rebuild the deleted local repository and continue to commit and push without harming the old commits?
Upvotes: 0
Views: 7121
Reputation: 631
If you have deleted the local repository, but you have pushed your commits to the GitHub repository, you only need to re-clone the project by doing git clone <url>
, and your work is ready...
Upvotes: 4
Reputation: 2028
You need to initialize a new Git repository in your machine:
git init
Add your remote repository (published on GitHub):
git remote add origin https://github.com/exampleusername/example_repo.git
fetch the origin:
git fetch
Then you can update your local branch with any branch you want:
git pull origin example_branch_name_you_want_to_take_update_from
Or you can simply clone the existing remote repository as suggested in the above comments:
git clone https://your_repot_url
Upvotes: 2