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

前端 未结 30 2486
不思量自难忘°
不思量自难忘° 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:40

    In order to go to a previous commit version of the file, get the commit number, say eb917a1 then

    git checkout eb917a1 YourFileName
    

    If you just need to go back to the last commited version

    git reset HEAD YourFileName
    git checkout YourFileName
    

    This will simply take you to the last committed state of the file

提交回复
热议问题