简体   繁体   English

如何“撤消”推送到远程Bonobo Git Server的提交?

[英]How can I “undo” a commit pushed to remote Bonobo Git Server?

I accidentely pushed the wrong changes to the Git Bonobo Server. 我不小心将错误的更改推到了Git Bonobo服务器上。 Can my commits be undone to where my commits are simply 'deleted'? 我的提交可以撤消到我的提交只是被“删除”的地方吗?

Forcing-pushing is potentially dangerous, as it can result in the permanent destruction of commits. 强制推送具有潜在的危险,因为它可能导致提交的永久破坏。 If you are not the sole contributor to the remote repository, then there is a chance you may obliterate someone else's changes. 如果您不是远程存储库的唯一贡献者,那么您很有可能会抹杀其他人的更改。 Even if you are the sole contributor to the remote repo, you should still only force-push when there are no alternatives and you are absolutely sure you won't destroy anything. 即使您远程回购的唯一贡献者,您也应该仅在没有其他选择的情况下强行推键,并且您绝对可以确保不会破坏任何东西。 If anyone else has pushed commits to the remote repository after your initial errant commit, then those commits will be lost forever if you force-push a hard reset. 如果在最初的错误提交之后,其他任何人都将提交推送到了远程存储库,那么如果您强行按下硬重置,这些提交将永远丢失。

To safely undo a commit that you've already pushed to the remote repository, you should instead revert the commit in question and then push the reversion to the remote repository like so: 为了安全地撤消已经推送到远程存储库的提交,您应该还原有问题的提交,然后将其还原到远程存储库,如下所示:

git revert [commit hash]
git push origin [branch]

This way, both the errant commit and the reversion of the errant commit will be visible in the history, and there is no risk of permanently losing any other changes in the remote repository. 这样,错误提交和错误提交的还原都将在历史记录中可见,并且没有永久丢失远程存储库中任何其他更改的风险。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM