Git 恢复到指定版本
步骤
查看要恢复的版本信息
# 查看历史记录 git log -3
实例
Simba@SIMBA MINGW64 /t/IDE/IDEA/Workspace-Learn/config-center (master) $ git log -3 commit 8026923afb29e79fcff76435ef7fe3389a7143e0 (HEAD -> master, origin/master, origin/HEAD) Author: Simba1949 <simba1949@outlook.com> Date: Fri Aug 2 21:30:29 2019 +0800 SpringClouConfig学习笔记之手动刷新数据 commit af05c43b5c6b14abbe9c6267811e4fb0a2d2b372 Author: Simba1949 <simba1949@outlook.com> Date: Sun Jul 28 17:27:54 2019 +0800 springcloud多环境配置文件 commit d124e2b35da7a9b51368e5f2d156b1128781c517 Author: Simba1949 <simba1949@outlook.com> Date: Sun Jul 28 16:39:14 2019 +0800 SpringCloudConfig 多环境配置文件
选择要恢复版本的 commit 值
# 恢复版本 git reset --hard af05c43b5c6b14abbe9c6267811e4fb0a2d2b372
实例
Simba@SIMBA MINGW64 /t/IDE/IDEA/Workspace-Learn/config-center (master) $ git reset --hard af05c43b5c6b14abbe9c6267811e4fb0a2d2b372 HEAD is now at af05c43 springcloud多环境配置文件
强制推送到远程服务器上
# 强制推送到远程仓库 git push -f origin master
实例
Simba@SIMBA MINGW64 /t/IDE/IDEA/Workspace-Learn/config-center (master) $ git push -f origin master Total 0 (delta 0), reused 0 (delta 0) To https://github.com/simba1949/config-center.git + 8026923...af05c43 master -> master (forced update)
演示
版本恢复前
执行命令信息
版本恢复后