要回退到之前的版本,可以使用以下命令:
使用 git log 查看历史版本的 commit ID
使用 git reset --hard <commit ID> 回退到指定的 commit ID
使用 git push origin <branch> --force 将本地的回退结果推送到远程仓库(注意:使用 --force 会覆盖远程仓库的历史记录,谨慎使用)
如果只是想撤销最近一次的 commit 操作,可以使用以下命令:
使用 git log 查看最近一次的 commit ID
使用 git reset --hard HEAD^ 回退到上一个 commit
使用 git push origin <branch> --force 将本地的回退结果推送到远程仓库(同样需要注意 --force 的使用)