在Sourcetree上移除/撤消合并 [英] Removing/undoing a merge on Sourcetree

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

问题描述

我在我的项目中做了很少的改变(我在做一个远程分支而不是主分支),我提交了它们并在 BitBucket 上创建了一个pull请求并合并掌握分支。在提交之后,我忘了推送我的更改。现在,在尝试将当前分支切换到远程分支并在合并之前恢复提交之后,我设法将所有更改都备份并备份到系统中的其他位置。我现在要做的就是撤销我做的坏事。每次我点击合并并选择反向提交时,我收到以下错误消息:



<$ p $

$ 错误:提交< commit_id>是一个合并但没有-m选项被给出

致命:恢复失败



这些分支现在看起来像这样:



我想基本上删除合并并将其带入这样的状态它不会说 master(4后面)了。



我是源代码管理新手,我会如果有人能帮助我解决这个问题,那就很感激了。

解决方案

此方法基于历史记录删除:


  1. 查看您犯的错误分支

  2. 右键单击要重置分支的提交

  3. 单击
  4. 选择Hard模式并单击确定。

  5. 不幸的是,您需要终端来完成这一步。输入 git push origin name_of_branch --force 到终端(您可能需要输入您的git repo用户名和密码才能接受命令)

如果稍后会弹出一条消息,询问您是要取消rebase还是继续。点击继续。如果您中止,合并将再次出现在本地副本上。



这可能是最简单的方法,但由于它基于历史记录删除,所以如果其他人在项目上工作,一定要让他们都知道你在做什么,这样你就不会破坏任何人的git仓库。


I made quite few changes in my project (I was working on a remote branch and not the master), I committed them and created a pull request on BitBucket and merged the branch to master. I had forgotten to push my changes after the commit. Now, after trying switching the current branch to my remote branch and reverting to the commit before the merge, I managed to get all my changes back and back them up elsewhere in my system. What I want to do now is undo the bad merge that I did. Each time I click on the merge and select "Reverse commit", I get the following error message:

"error: Commit <commit_id> is a merge but no -m option was given.

 fatal: revert failed"

The branches look like this now:

I want to basically remove the merge and bring it to a state such that it doesn't say master(4 behind) anymore.

I am new to source control and I would appreciate it if anyone could help me out with this.

解决方案

This method is based on history deletion:

  1. Check out the branch you made the mistake on
  2. Right click on the commit you want to reset the branch to
  3. Click "Reset current branch to this commit"
  4. Select "Hard" mode and click "OK"
  5. Unfortunately you need terminal to do this bit. Type git push origin name_of_branch --force into terminal (you may need to enter your git repo username and password for it to accept the command)

If a message pops up later down the line asking if you would like to abort the rebase or continue. Click "continue". If you abort, the merge will appear on your local copy again.

This is probably the easiest way to do it but since it is based on history deletion, If others are working on the project, make sure to let them all know what you are doing so you don't break anyone's git repository.

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

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