Git 怎么把某个文件回滚到历史版本?
通用的做法
比如要回滚main.js 文件
git log main.js 首先找到需要回滚版本的hash值
git checkout hash value main.js
git commit -m'rollback main.js' 回滚了需要提交。
在乌龟里面怎么实现?
-
Checkout some file(s) of its previous revision
(a) Right click the file you want to revert and Show Log for that file
(b) Right click the file in file list and perform Revert to parent revision
(c) repeat (a), (b) until you get all files you want.
-
Testing
-
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)
(Tested on TortoiseGit 1.8.16.1, GfW 2.6.4.windows.1, Win 10 64bit)