Git的力量恢复到HEAD〜7 [英] Git force revert to HEAD~7
问题描述
谢谢!
是推动另一个提交意外提交的提交。请参阅 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屋!