Eclipse中撤消git push提交

文章目录

    • 一、目标
      • 1. 目的:撤消git(码云)上最新的一次提交
      • 2. eclipse版本
    • 二、操作步骤
      • 0. 另存当前代码
      • 1. 本地git仓库还原到前一个版本
      • 2. 提交当前还原的版本
      • 3. 之前备份覆盖当前项目

一、目标

1. 目的:撤消git(码云)上最新的一次提交

Eclipse中撤消git push提交_第1张图片

2. eclipse版本

Eclipse IDE for Enterprise Java Developers.
Version: 2018-12 (4.10.0)
Build id: 20181214-0600

二、操作步骤

0. 另存当前代码

  • 还原后再覆盖回来,这样就回到了上次冲动提交的前一秒

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

  • 选中项目右键 -》 Team -》 Show in History

Eclipse中撤消git push提交_第2张图片

  • 选中上一个版本右键 -》Reset -》 Hard(HEAD,Index and Working Tree)

Eclipse中撤消git push提交_第3张图片

  • 点击Reset,还原

  • 此时本地代码回到了前一个版本,但git上没有任何改变

Eclipse中撤消git push提交_第4张图片

  • 同时可以发现,项目本身提示git有可更新版本

Eclipse中撤消git push提交_第5张图片

2. 提交当前还原的版本

  • 选中项目右键-》Team -》Push Branch ‘master’…
    注:不要选择Push to Upstream

Eclipse中撤消git push提交_第6张图片

  • 取消 Configure upstream for push and pull
  • 勾选 Force overwrite branch in remote if it exists and has diverged

Eclipse中撤消git push提交_第7张图片

  • 点击Preview

Eclipse中撤消git push提交_第8张图片

  • 点击Push

Eclipse中撤消git push提交_第9张图片

  • 提交成功
    1.项目不再提示有可更新版本

Eclipse中撤消git push提交_第10张图片

  1. 码云上的提交记录已消失(毁尸灭迹)

Eclipse中撤消git push提交_第11张图片

3. 之前备份覆盖当前项目

  • so happy,回到了提交前的状态

你可能感兴趣的:(git(eclipse))