8

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

pengguang001
  • 4,045
  • 6
  • 27
  • 31

1 Answers1

13

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.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • Thanks! So, is it possible checkout a specified folder to that commit, but leave others unchanged? – pengguang001 Apr 28 '11 at 13:50
  • 2
    @soul2003: well, you can - e.g. `git checkout -- tests/` will revert your working tree (and the staging area) for the `tests` subdirectory to the state at ``. However, asking that question raises the larger one of "what problem are you really trying to solve?" - I suspect that's not what you really want to do... – Mark Longair Apr 28 '11 at 14:01
  • 2
    @soul2003: I find "can you x?" questions in git easiest to look up in the [visual git reference](http://marklodato.github.com/visual-git-guide/index-en.html). – jtniehof Apr 28 '11 at 14:09