Git 怎么把某个文件回滚到历史版本?

通用的做法

比如要回滚main.js 文件

git log main.js  首先找到需要回滚版本的hash值

git checkout  hash value main.js

git commit -m'rollback main.js'  回滚了需要提交。

在乌龟里面怎么实现?

  1. Checkout some file(s) of its previous revision

    (a) Right click the file you want to revert and Show Log for that file

    enter image description here

    (b) Right click the file in file list and perform Revert to parent revision

    enter image description here

    enter image description here

    (c) repeat (a), (b) until you get all files you want.

    enter image description here

  2. Testing

  3. Revert to current revision

    (a) perform Revert... in context menu of explorer

    This way, you can choose the file(s) you want to revert.

    (b) or this quick way: perform Reset Hard in Log dialog

    This way, all changed files revert. (=> Lost all working dir changes)

    enter image description here

    enter image description here

(Tested on TortoiseGit 1.8.16.1, GfW 2.6.4.windows.1, Win 10 64bit)

posted @ 2021-03-31 00:17  LearningAlbum  阅读(685)  评论(0)    收藏  举报