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

前端 未结 30 2428
不思量自难忘°
不思量自难忘° 2020-11-21 11:23

I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous versio

30条回答
  •  萌比男神i
    2020-11-21 11:43

    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.

提交回复
热议问题