Git取消恢复 [英] Git cancel a revert

查看:106
本文介绍了Git取消恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在git中,假设我提交了A和B

  A --- [B] 

但是,我回复了

  git revert HEAD 

所以我现在在那里:

  [A] --- B 

是否取消我的回复,以便我可以回到B?




  • 恢复回复提交(创建第二个回复提交,将您带回原始文件)

  • 丢弃回复提交




git reset --hard HEAD ^




第二个选项仅适用于 在其他任何地方推送您的更改。事实上,如果你还没有在任何地方推动你的第一次恢复提交,你可以简单地使用


git reset --hard

>

无需创建任何还原提交即可回滚。

In git let say I commit A and B

A---[B]

But then I revert with

git revert HEAD

So I am there now:

[A]---B

How do I cancel my revert so that I can go back to B?

解决方案

You have two general choices:

  • Revert the revert commit (creating a second revert commit that takes you back to the original)
  • Throw away the revert commit with

git reset --hard HEAD^

The second option is only appropriate if you have not pushed your changes anywhere else. In fact, if you haven't pushed your first revert commit anywhere yet, you can simply use

git reset --hard

to roll back without creating any revert commits at all.

这篇关于Git取消恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆