Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the command to reset a file to a specific commit? [duplicate]

Tags:

git

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?

like image 446
Adam Lee Avatar asked Dec 30 '14 15:12

Adam Lee


1 Answers

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
like image 185
michas Avatar answered Sep 29 '22 13:09

michas