删除bitbucket中的最后一次提交 [英] Delete last commit in bitbucket

查看:131
本文介绍了删除bitbucket中的最后一次提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我犯了一个错误,我不知道如何删除存储库中的最新推送.我提取了该应用程序的最新更新,但是有冲突,因此将其推送到存储库中.

I made a mistake and I don't know how to delete my latest push in the repository. I pull the latest updates of the app but it has conflicts and I push it to repository.

如何删除我的上一次提交?或如何解决?

How to delete my last commit? Or how to fix it?

推荐答案

首先,如果您正在同一个代码存储库中与其他人一起工作,则不应删除提交,因为您在存储库上强制进行更新,它将使您的同事的本地存储库处于非法状态(例如,如果他们在您删除的同事之后进行了提交,则这些提交将是无效的,因为它们基于现在不存在的提交).

In the first place, if you are working with other people on the same code repository, you should not delete a commit since when you force the update on the repository it will leave the local repositories of your coworkers in an illegal state (e.g. if they made commits after the one you deleted, those commits will be invalid since they were based on a now non-existent commit).

表示,您可以做的是还原提交.根据您使用的CVS,此过程的执行方式有所不同(不同的命令):

Said that, what you can do is revert the commit. This procedure is done differently (different commands) depending on the CVS you're using:

git 上:

git revert <commit>

mercurial :

hg backout <REV>

还原操作创建的新提交的作用与还原的提交相反(例如,如果原始提交添加了一行,则还原提交将删除该行),从而有效地删除了不需要的提交的更改,而无需重写存储库历史记录.

The revert operation creates a new commit that does the opposite than the reverted commit (e.g. if the original commit added a line, the revert commit deletes that line), effectively removing the changes of the undesired commit without rewriting the repository history.

这篇关于删除bitbucket中的最后一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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