git 在 Bitbucket 上恢复合并的拉取请求

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38302119/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:21:08  来源:igfitidea点击:

Revert a merged pull request on Bitbucket

gitbitbucketatlassian-sourcetree

提问by Jordi

I've created a pull request and I've merged it to an wrong branch. How can I revert it?

我创建了一个拉取请求,并将它合并到一个错误的分支。我怎样才能恢复它?

As far I've been to figuring out taking a look over there, I'm able to hard reset the destination branch... but, how about the pull request in originrepository?

到目前为止,我一直想看看那边,我能够硬重置目标分支……但是,origin存储库中的拉取请求怎么样?

I'm using Bitbucket and I've created the pull request from SourceTree (opening the Bitbucket page).

我正在使用 Bitbucket 并且我已经从 SourceTree 创建了拉取请求(打开 Bitbucket 页面)。

I've three branches I'm working on: master, devand create-alias. create-aliaswas set up from devand devfrom master: master -> dev -> create-alias. The problem is I made a pull request from create-aliasand I did merge it into masterinstead of dev.

我正在处理三个分支:master,devcreate-alias. create-alias是从devdevmaster: 设置的master -> dev -> create-alias。问题是我提出了一个拉取请求create-alias,我确实将它合并到master而不是dev.

I'm working on create-aliasbranch right now. The last commit on create-aliasis 6ee20f9and the merged commit on masteris be36f72.

我现在在create-alias分支上工作。最后一次提交create-alias6ee20f9,合并提交masterbe36f72

Could you write me down a bit about who to step-by-step revert it?

你能帮我写下关于谁来逐步恢复它吗?

As far I've been able to figure out:

到目前为止,我已经能够弄清楚:

  1. checkout on master.
  2. revert -m 1 6ee20f9.
  3. push.
  4. checkout on create-aliasand going on working.
  1. 结帐master
  2. 恢复 -m 1 6ee20f9
  3. 推。
  4. 结帐create-alias并继续工作。

Isn't it?

不是吗?

回答by Will

Unfortunately, there is no "Revert Pull Request" feature on Bitbucket as of this writing, but a feature request exists for it.

不幸的是,在撰写本文时,Bitbucket 上没有“恢复拉取请求”功能,但存在一个功能请求

Note: Before you proceed, make sure your working copy is clean, with no uncommitted or unpushed changes.

注意:在继续之前,请确保您的工作副本是干净的,没有未提交或未推送的更改。

So, you'll have to revert the merge in Git. First, find the SHA hash of the merge commit.

因此,您必须在 Git 中恢复合并。首先,找到合并提交的 SHA 哈希值。

On the command line, this is:

在命令行上,这是:

git checkout <branch>
git pull
git log

Then, we revert the merge commit and push it:

然后,我们恢复合并提交并推送它:

git revert -m 1 <SHA-1>
git push

In SourceTree, first checkout the branch in question, then Pull. Find the merge commit in the log window, then right click it, and click Copy SHA-1 to Clipboard.... Then go to Actions --> Open in Terminal. Once the terminal opens, type:

在 SourceTree 中,首先检出有问题的分支,然后Pull。在日志窗口中找到合并提交,然后右键单击它,然后单击Copy SHA-1 to Clipboard...。然后转到Actions --> Open in Terminal。终端打开后,输入:

git revert -m 1 <SHA-1 (from clipboard)>
git push

Unfortunately, SourceTree doesn't have a way to simply right-click and revert a merge, but a feature request exists for it.

不幸的是,SourceTree 无法简单地右键单击并恢复合并,但存在针对它功能请求

回答by oknate

Bitbucket has a "revert" button on Pull Requests now.

Bitbucket 现在在 Pull Requests 上有一个“revert”按钮。

enter image description here

在此处输入图片说明

Note it doesn't automatically update the branch the original PR was merged into it. It creates a new branch with a commit that reverts the PR:

请注意,它不会自动更新原始 PR 合并到其中的分支。它创建一个带有恢复 PR 的提交的新分支:

enter image description here

在此处输入图片说明

You then can create a PR from this branch and merge it.

然后你可以从这个分支创建一个 PR 并合并它。

回答by Pieter Du Toit

Bitbucket now has the 'Merge Pull Request' feature released. Follow this linkto learn more.

Bitbucket 现在发布了“合并拉取请求”功能。点击此链接以了解更多信息。