restore撤回暂存
查看状态
撤回暂存
restore 将文件复原到目标版本
git restore -s 目标提交hash 文件路径
restore 将文件回退到上一个版本
git restore -s HEAD~1 文件路径
restore 撤销commit至上一次commit
git reset --sfot HEAD^
amend修改提交
如果对上一次的提交的注释不满意,可以修改注释
git commit --amend
如果相对上一次提交增加新的内容,即:增加修改操作,但是不产生新的提交。
git add ./
git commit --amend
向后移动HEAD
向后移动一步
git reset --soft HEAD~
本质上是撤销了上一次git commit命令。
当你运行git commit时,Git会创建一个新的提交,并移动HEAD所指向的分支来使其指向该提交。
这个操作动head,同时带着分支一起移动,但工作区不变
checkout 切换分支时,只动head不修改分支
将工作区设置到当前head处
这个命令很危险,能够把当前工作区的修改完全抹去。
git reset --hard HEAD
查看HEAD的移动记录
git reflog --oneline
向前移动HEAD
git reset --soft 目标commit的hash
恢复某一分支
git branch 新分支名 目标提交对象的hash