撤销推送至远程仓库操作(备忘)

267 阅读1分钟

撤销提交信息

通过git log查看提交信息,以便获取需要回退至的版本号:

通过git reset –soft 版本号重置至指定版本的提交(版本号为要撤回提交的上一个版本号),达到撤销提交的目的

通过git push origin master –force强制提交当前版本号

若不强制提交则会报一个版本号比远程低的错误

error: failed to push some refs to 'git@github.com:hanchao5272/myreflect.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

修改代码,重新提交和推送

git add .
//重新提交
git commit -m ""
//重新推送
git push