I would like to know how to do a pull from repo based on a SHA?
git pull origin master
the above code will pull master once we've done git add remote
.
To pull up a list of your commits and their associated hashes, you can run the git log command. To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.
As is well-known, Git has been using SHA-1 to calculate a hash for each commit: For example, files, directories, and revisions are referred to by hash values unlike in other traditional version control systems where files or versions are referred to via sequential numbers.
When comparing Git pull vs fetch, Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn't make any changes to your local files. On the other hand, Git pull is faster as you're performing multiple actions in one – a better bang for your buck.
A git pull does two things for you:
It sounds like what you want to do is to get a specific revision from the repository and merge it with your current branch.
The best way to do this is two commands:
git fetch origin
git merge YOUR_SHA_HERE
If what you want is just to see what's in a specific revision from the repository and make it the working tree, but not do a merge, then you would want:
git fetch origin
git checkout YOUR_SHA_HERE
If what you want is to get the specific version, and make it the new "master" (or another branch), then you would want to run
git fetch origin
git reset --hard YOUR_SHA_HERE
All of these will fetch new code from the repository (via the 'git fetch origin'), but then there are different ways to combine with / replace your current code.
I don't think there's a way to pull just part of a branch based on a SHA.
What's wrong with:
git pull
git reset --hard <sha>
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