Alex Rivera | Logout

How can I reset or revert a file to a specific revision?

Asked 2008-10-18T23:34:02.570
5894

How can I revert a modified file to its previous revision at a specific commit hash (which I determined via git log and git diff)?

Edit
Report

1 Answer

117

I had the same issue just now and I found this answer easiest to understand (commit-ref is the SHA value of the change in the log you want to go back to):

git checkout [commit-ref] [filename]

This will put that old version in your working directory and from there you can commit it if you want.

answered 2009-05-27T17:52:22.760

Your Answer