The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .
If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
To reference a commit, simply write its SHA-hash, and it'll automatically get turned into a link.
First, clone the repository using git, e.g. with:
git clone git://github.com/facebook/facebook-ios-sdk.git
That downloads the complete history of the repository, so you can switch to any version. Next, change into the newly cloned repository:
cd facebook-ios-sdk
... and use git checkout <COMMIT>
to change to the right commit:
git checkout 91f25642453
That will give you a warning, since you're no longer on a branch, and have switched directly to a particular version. (This is known as "detached HEAD" state.) Since it sounds as if you only want to use this SDK, rather than actively develop it, this isn't something you need to worry about, unless you're interested in finding out more about how git works.
I don't know if it was there when you had posted this question, but the best and easiest way to download a commit is to click on the commits tab when viewing a repository. Then instead of clicking on the commit name, click on Browse the repository at this point in the history button with <> symbol to the right side of the commit name/message, and finally on the Download ZIP button that comes when you click Clone or Download button.
I hope it helps you guys.
Sivan's answer in gif
1.Click on commits in github
2.Select Browse code on the right side of each commit
3.Click on download zip , which will download source code at that point of time of commit
To just download a commit using the 7-digit SHA1 short form do:
Working Example:
https://github.com/python/cpython/archive/31af650.zip
Description:
`https://github.com/username/projectname/archive/commitshakey.zip`
If you have the long hash key
31af650ee25f65794b75d4dfefed6fe4758781c1
, just get the first 7 chars31af650
. It's the default for GitHub.
The easiest way that I found to recover a lost commit (that only exists on github and not locally) is to create a new branch that includes this commit.
git pull
the new branch down to localTry the following command sequence:
$ git fetch origin <copy/past commit sha1 here>
$ git checkout FETCH_HEAD
$ git push origin master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With