4

step1
image.png
在src/main.js文件里面添加了一行console.log('reset')
image.png
在src/App.vue文件里面添加了console.log('this is used to test git reset -mixed')
将上面的内容同步到远端

step2
查看App.vue文件的提交记录
git log src/App.vue(退出是q)
WeChat62fd1703069120cca5f8b0913087a238.png
图片中1是我刚刚最新上传的(称为new),2是我要恢复到的版本号(称为Previous)

step3
image.png
这个时候你(staged)暂存的就是(previous)
image.png
(unstaged)没有暂存的就是最新的
3.1此时你执行 git commit -m 'rest -mixed'就会被你commit到本地的分支上面
3.2你再执行 git checkout src/App.vue 就会把工作区(也就是没有add)的文件恢复到原样(git checkout . 是把工作区的都删除)
3.3 在执行git push 就把远端的App.vue文件恢复到 Previous了

赶脚是不是很麻烦呢~~~~~~~~~
⭐️有个比较简单的办法哦
step1
git checkout 版本号 文件路径
(eg:
git checkout 8e13ed41d4e9ea335a6cf7a9653ac43ba8a8633a src/App.vue)
step2
执行commit
step3
再执行push就好啦


yellowDog
28 声望3 粉丝