Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning an older version of github repo

I have an Amazon EC2 machine. I would like to clone an older version of github repo on this machine. Normally I use git clone https://linktomyrepo.git How can I clone an older version, say an update from 14 days ago? I can see the exact version I need in the commit history of repository, but do not know how to clone it onto the EC2 machine. Do I need to use the little SHA code next to each commit?

like image 681
Mobie Avatar asked Sep 04 '12 02:09

Mobie


People also ask

Can you duplicate a GitHub repo?

On GitHub.com, navigate to the main page of the repository. Above the list of files, click Code. Click Open with GitHub Desktop to clone and open the repository with GitHub Desktop. Follow the prompts in GitHub Desktop to complete the clone.

How do I get an older version of a git code?

To move HEAD around in your own Git timeline, use the git checkout command. There are two ways to use the git checkout command. A common use is to restore a file from a previous commit, and you can also rewind your entire tape reel and go in an entirely different direction.


1 Answers

You can always check out any given state by using a commit hash.

For instance, by looking at the log, you identified that 233ab4ef was the state you were interested in: issue a git checkout 233ab4ef to check out that state.

Another way to achieve this is by using git checkout @{14.days.ago}

like image 87
Olivier Refalo Avatar answered Sep 23 '22 13:09

Olivier Refalo