Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - fetch an intermediate commit

Tags:

git

Is there any git command to fetch an intermediate commit, just like 'svn co -r xxx' works? Thanks!

like image 492
pengguang001 Avatar asked Apr 28 '11 13:04

pengguang001


People also ask

Can I pull a specific commit?

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 .

Should I fetch before commit?

It's important to fetch and pull before you push. Fetching checks if there are any remote commits that you should incorporate into your local changes. If you see any, pull first to prevent any upstream merge conflicts.

Should I use git pull or fetch?

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.

How do I fetch in git?

When you do a git fetch, it fetches all the changes from the remote repository and stores it in a separate branch in your local repository. You can reflect those changes in your corresponding branches by merging. So basically, git pull = git fetch + git merge.


1 Answers

git checkout <commit-id>, where <commit-id> is the SHA1 of a commit, a tag, or a branch.

Note that in git vocabulary, fetch refers to connecting to a remote repository and grabbing its commits.

like image 83
CharlesB Avatar answered Oct 21 '22 10:10

CharlesB