1

I have made several commits to a file. How could a get back to a specific version of time of that file?

Thanks.

smwikipedia
  • 61,609
  • 92
  • 309
  • 482
  • possible duplicate of [How can I check out a particular version of one file in Git?](http://stackoverflow.com/questions/1173676/how-can-i-check-out-a-particular-version-of-one-file-in-git) – Felix Kling Aug 29 '11 at 14:56

2 Answers2

4

Use git log to see the commits you made and choose the one you want to get back. Note its SHA1 hash.

Then use git checkout to get to that version of the file:

git checkout f93b3e path/to/file

In fact, any tree-ish will work here. For instance, if you wanted the file as it was last month you could do:

git checkout master@{1 month ago} path/to/file
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
0

If you want a visual tool use gitk from the branch in question.

As you select various commits you can inspect content to find the right one.

You can right click on the commit to check out the whole commit out as a 'detached head', that is, it will be detached from the branch's tip.

Philip Oakley
  • 13,333
  • 9
  • 48
  • 71