# git 撤回指定合并 git撤回命令 git撤回指定提交 git合并回退 git合并之后撤销

278 阅读1分钟

git 撤回指定合并 git撤回命令 git撤回指定提交 git合并回退 git合并之后撤销

branch_name: 当前分支名

commit_hash: 提交的commit_id

建议打开git仓库先基于需要操作的分支进行备份,也可方便查看commit_hash

git 回滚 (无痕)

需要在记录中查找到 commit_id

git log   // 按q键退出查询状态

git命令进行回滚(无痕)

git reset --hard  <commit_hash>

将回滚的代码提交

git push -f origin <branch_name>

git 回退(有记录)

查询commit_id

git log   // 按q键退出查询状态

git命令进行回退(有痕)

git reset --soft  <commit_hash>

将代码提交

git commit -m '提交文案'
git push origin <branch_name> -f   // 注意:本地的代码就是回滚的代码 看情况是否需要提交

git 撤销指定提交记录

git revert <commit_hash>
git push origin <branch_name>