如何撤消Bitbucket上的合并? [英] How to undo a merge on Bitbucket?

查看:803
本文介绍了如何撤消Bitbucket上的合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个合并(进入主分支),这个合并现在位于Bitbucket回购协议中。长话短说:我需要撤消合并。

我知道你可以在Github网站上做到这一点,但是Bitbucket没有这个功能。我不清楚在Git中如何做到这一点,而不会造成混乱。

你需要首先克隆存储库您的本地系统(您可以从Bitbucket中的资源库的Overview页面以SSH或HTTPS格式获取repo URL):

  git clone git@bitbucket.org:my / repo.git 
- 或 -
git clone https://my@bitbucket.org/my/repo.git

git checkout master

..然后恢复最近的提交。首先列出可用的提交:

  git log 

..然后选择合并前的提交:

  git reset  - hard 72ead1c4c1778c23c277c4f15bbb68f3bb205f54 

..其中hash是合并前的提交的哈希值(来自日志) 。最后,强制推回到Bitbucket,覆盖历史记录。

  git push -f 

当然,如果repo是共享的,并且其他用户已经将最近的提交拉回到顶层,那么它们就不会很开心。所以在这种情况下,一定要通知所有人你在做什么。



revert 其他答案是另一种选择;它会保留您所做的提交,但会进一步修改存储库(使用新的提交),以便解除您所做的更改。您是否想使用 revert 取决于您是否希望提交中的信息保留在回购记录中。



有关在git中取消更改的更多详细信息,请参阅 Atlassian的良好教程页面


I've created a merge (into the 'master' branch) that's now on a Bitbucket repo. Long story short: I need to undo that merge.

I know that you can do this at the Github site itself, but Bitbucket doesn't have that feature. I'm not clear on how to do this with Git without causing a mess.

解决方案

You need to first clone the repository on your local system (you can get the repo URL in SSH or HTTPS format from the "Overview" page of the repository in Bitbucket):

git clone git@bitbucket.org:my/repo.git
-or-
git clone https://my@bitbucket.org/my/repo.git

git checkout master

.. then revert the most recent commit. First list the available commits with:

git log

.. then select the commit before the merge:

git reset --hard 72ead1c4c1778c23c277c4f15bbb68f3bb205f54

.. where the hash is the hash of the commit before the merge (from the log). Finally, force-push the changes back to Bitbucket, overwriting history.

git push -f

Naturally if the repo is shared, and its other users have pulled your most recent commit and built atop it, they won't be happy. So in that case be sure to notify everybody of what you're doing.

revert, as mentioned in the other answers is another option; it keeps the commit you made, but modifies the repository further (with a new commit) in such way that it undoes the changes you made. Whether you want to use revert depends on whether you want the information in your commit to remain in the repo history or not.

For more detail on undoing changes in git, see a good tutorial page by Atlassian.

这篇关于如何撤消Bitbucket上的合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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