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

前端 未结 30 1943
不思量自难忘°
不思量自难忘° 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条回答
  •  感情败类
    2020-11-21 11:56

    I think I've found it....from http://www-cs-students.stanford.edu/~blynn/gitmagic/ch02.html

    Sometimes you just want to go back and forget about every change past a certain point because they're all wrong.

    Start with:

    $ git log

    which shows you a list of recent commits, and their SHA1 hashes.

    Next, type:

    $ git reset --hard SHA1_HASH

    to restore the state to a given commit and erase all newer commits from the record permanently.

提交回复
热议问题