How to revert only one file back to a revision or commit

I messed up with one file in one repository and want to check out only that file back to a commit. How to achieve this?

asked Feb 12, 2014 by Eric Z Ma (44,280 points)

1 Answer

Best answer

To check the file with at git commit commit_sha1:

$ git checkout commit_sha1

You can also use the relative commit instead of commit_sha1 such as master~4, HEAD~4, HEAD^, master^ and etc.

To check back (the master) of

$ git checkout master
answered Feb 18, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost