[英]Git revert several commit from internal github
There is a way to revert 4 commits which pushed to github to previos commit, for example the master is now in有一种方法可以将推送到 github 的 4 次提交还原为以前的提交,例如 master 现在在
60cd87e7de2306279f7155d1366f468515a0319g
and I want to revert it (the master) to我想把它(主人)恢复到
70bc987ac1dcaa43af19699859a8a09d8006253w
Can I do it from git hub or any other simple way will be very helpful.我可以从 git hub 或任何其他简单的方式来做这件事会非常有帮助。
I did in the IDE web storm revert like我在 IDE 网络风暴中做了类似的恢复
git reset --hard 70bc987ac1dcaa43af19699859a8a09d8006253w git reset --hard 70bc987ac1dcaa43af19699859a8a09d8006253w
but not sure how to do this as the new(old) master但不知道如何作为新(旧)主人这样做
You can't properly reset your master to an old state without a force push
.如果没有force push
您将无法正确地将 master 重置为旧状态。
What you can do is issue this command你可以做的是发出这个命令
git log 60cd87e7de2306279f7155d1366f468515a0319g
Copy the id of the commits until (but not including) the commit you want to revert do, and revert them by adding negative commit, in the reverse order :复制提交的 id 直到(但不包括)您要还原的提交,然后通过添加否定提交以相反的顺序还原它们:
git revert commit_A
git revert commit_B
git revert commit_C
git revert commit_D
This will create 4 commits.这将创建 4 个提交。
Then, push them normally with然后,正常推动它们
git push origin master
If nobody else has cloned this repository, you don't care about the history and you really know what you're doing, you can issue a force push如果没有其他人克隆了这个存储库,你不关心历史并且你真的知道你在做什么,你可以发出强制推送
git push --force origin master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.