Git的力量恢复到HEAD〜7 [英] Git force revert to HEAD~7

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

问题描述

我犯下了一些不好的事情。我如何强制恢复我的本地回购到HEAD〜7,并重新提交,以便HEAD现在在该版本? Git docs confuse me。



谢谢!

解决方案

是推动另一个提交意外提交的提交。请参阅 JakubNarębski的回答,了解如何操作。



如果出于某种原因,推送不是快进的更新(例如提交中的敏感比特)可能不太合适,请给出以下命令:

 git reset --hard HEAD〜7 
git push --force origin master

第一个倒带你当前的分支。这是一个尖锐的工具,所以要小心。



为了防止你意外丢失工作,git不会推动你的倒带分支。 - force 选项禁用此安全功能。


I committed and pushed some bad things. How do I force revert my local repo to HEAD~7, and re-commit so that HEAD is now at that version? Git docs confuse me.

Thanks!

解决方案

The nicest approach is to push another commit that reverts the unintended commits. See Jakub Narębski's answer on how to do that.

If for some reason it's worth the potential unfriendliness of pushing an update that isn't a fast-forward (sensitive bits in the commits, for example), give these commands:

git reset --hard HEAD~7
git push --force origin master

The first rewinds your current branch. This is a sharp tool, so be careful.

To stop you accidentally losing work, git won't push your rewound branch. The --force option disables this safety feature.

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

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