7

Using git, is there a command which I can reset a file to a specific commit in the commit log?

I know git checkout file can let me reset the file to HEAD, but how to reset to a specific commit version?

Adam Lee
  • 24,710
  • 51
  • 156
  • 236

1 Answers1

8

Mind your terminology. With git "reset" refers to setting a ref (e.g. branch) to a new commit. You want to put a file from some commit into your working copy. Exactly this is a "checkout".

You can checkout all files of a commit with

git checkout commit

or only part of the commit with

git checkout commit file

If you only want to "show" a file of some commit without changing your working copy you can also use

git show commit:file
michas
  • 25,361
  • 15
  • 76
  • 121
  • Also, to avoid ambiguity between file names and ref names, you may need to `git checkout commit -- file`... – twalberg Dec 30 '14 at 17:55