Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the entire git repository [duplicate]

Tags:

git

I accidentally deleted some files from my source directories. I need to just re-fetch the entire git repository (git pull doesn't work because these files haven't changed since my last commit). My repository is up to date. How do I just get the entire repository? It's OK if it overwrites what's there

like image 885
Jeff Hornby Avatar asked Mar 20 '13 22:03

Jeff Hornby


People also ask

How do I clone an entire git repository including branches?

The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.

How do I download entire git repository?

When downloading materials to your laptop, it is easiest to download the entire repository. To do this, go to the GitHub page for the workshop, click on the green Code button, then download the repository as a ZIP file. The filename may be different than what's in the picture. Find the downloaded .


2 Answers

Your repo's files are already inside the .git directory stored as git objects. You just need to switch your working copy's state to an untouched one.

Run the following command from the root of your repo to unstage any changes you have in the git's staging area:

git reset HEAD .

Then run the following command, to discard all changes in the currently checked out branch:

git checkout -- .

git pull is required only if you need to fetch updated changes from the remote repository into your local one and merge the remote changes for the current branch into the local one. Based on what I understood from your question at least, git pull is not required.

like image 113
Tuxdude Avatar answered Sep 27 '22 15:09

Tuxdude


There are two simple way to reset your checkout:

git checkout .

This will reset your checkout to the state of your current branch.

git reset --hard origin/master

This will reset your checkout to the state of your remote tracking branch (assumed to be master). This is useful if you've made some commits locally, which you don't care to keep.

like image 28
AD7six Avatar answered Sep 27 '22 17:09

AD7six