eclipse 恢复 git master 主分支

git上误提交代码时(我同事错误提交了主分支代码,且主分支显示master,master,之前的提交次数在git浏览器上不再展示),可根据以下步骤回滚错误提交的代码及记录:

1. 本地git仓库还原到前一个版本

  • 选中项目右键 -》 Team -》 Show in History
  • 选中上一个版本右键 -》Reset -》 Hard(HEAD,Index and Working Tree)

2. 提交当前还原的版本

  • 选中项目右键-》Team -》Push Branch -》master
  • 取消 Configure upstream for push and pull
  • 勾选 Force overwrite of branch on remote if it exists and has diverged
  • 点击Next-》 push

push成功后,git上主分支恢复,且之前错误的记录已删除

posted @ 2020-03-02 21:48  jason_woo  阅读(631)  评论(0)    收藏  举报