[英]GitHub - Remove pushed commits without affecting local repository
What is the best way to remove commits from GitHub without affecting my local repositories since i made some commits that i wish to keep? 自从我做了一些我希望保留的提交以来,从GitHub删除提交而不影响我的本地存储库的最佳方法是什么?
Github repository has two wrong commits that i desire to remove while keeping the commits on my local repository. Github存储库有两个错误的提交,我希望将其删除,同时将提交保留在本地存储库中。
Assuming the current repository state is this: 假设当前存储库状态为:
server: A---B---C---D
^master
workstation: A---B---C---D
^HEAD
^master
^origin/master
And the desired state is this: 所需的状态是这样的:
server: A---B
^master
workstation: A---B---C---D
^HEAD
^master
^origin/master
Then what you can do to get there is this: 然后,您可以执行以下操作:
$ git push --force origin bbbbbbbb:master
where bbbbbbbb
is the commit hash of B. 其中
bbbbbbbb
是B的提交哈希。
Notes: 笔记:
--force
, be careful. --force
,要小心。 You can get yourself into a place that's difficult to come out of.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.