'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?
Solution 1:[1]
Git is not designed that way. When you clone a repository, you are copying all versions.
So first clone a repository (which does initially checkout the latest version), then checkout the version you actually want.
You can checkout the commit based on the hash.
git checkout afe52
You can also checkout based on date (instead of looking up the hash), eg:
git checkout 'master@{1979-02-26 18:30:00}'
git checkout @{14.days.ago}
To check the commits you can checkout, use git log.
Solution 2:[2]
Also for Github.com UI,
For those wanting to download a specific Commit, steps are below:
- Go to "Commits"
- Click the "<>" icon to the right of the desired commit
- Select Clone or Download
- Download ZIP
Solution 3:[3]
Posting this solution specifically for github.com UI.
I was using an older version of Keycloak and wanted to download the source. On github.com, it was a simple process:
- Go to releases section
- Download the required release.
Solution 4:[4]
Old version on Github usually means an old branch. For example:
In this case you can check out the old branch by using its branch name:
git clone --branch <branchname> <remote-repo-url>
The you can get here:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ronalchn |
| Solution 2 | |
| Solution 3 | tryingToLearn |
| Solution 4 | Gerfried |




