6

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
  • 23,314
  • 47
  • 144
  • 221

1 Answers1

7

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
  • 24,015
  • 14
  • 69
  • 112
  • 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