Cloning an older version of github repo
GitGithubGit CheckoutGit Problem Overview
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?
Git Solutions
Solution 1 - Git
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}
Solution 2 - Git
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 3 - Git
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 4 - Git
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.