简体   繁体   English

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

[英]Revert a merged pull request on Bitbucket

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 origin repository?到目前为止,我一直想看看那边,我能够硬重置目标分支……但是, 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 , dev and create-alias .我正在处理三个分支: masterdevcreate-alias create-alias was set up from dev and dev from master : master -> dev -> create-alias . create-alias是从devdevmastermaster -> dev -> create-alias The problem is I made a pull request from create-alias and I did merge it into master instead of dev .问题是我从create-alias提出了一个拉取请求,我确实将它合并到master而不是dev

I'm working on create-alias branch right now.我现在正在create-alias分支。 The last commit on create-alias is 6ee20f9 and the merged commit on master is be36f72 . create-alias上的最后一次提交是6ee20f9master上的合并提交是be36f72

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 .master结帐。
  2. revert -m 1 6ee20f9 .恢复 -m 1 6ee20f9
  3. push.推。
  4. checkout on create-alias and going on working.结帐create-alias并继续工作。

Isn't it?不是吗?

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. 因此,您必须还原Git中的合并。 First, find the SHA hash of the merge commit. 首先,找到合并提交的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 . 在SourceTree中,首先检出相关分支,然后检出Pull Find the merge commit in the log window, then right click it, and click Copy SHA-1 to Clipboard... . 在日志窗口中找到合并提交,然后右键单击它,然后单击“ 将SHA-1复制到剪贴板...” Then go to Actions --> Open in Terminal . 然后转到操作->在终端中打开 Once the terminal opens, type: 终端打开后,键入:

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无法简单地右键单击并还原合并,但是有一个功能请求

Bitbucket has a "revert" button on Pull Requests now. Bitbucket现在在“拉取请求”上有一个“还原”按钮。

在此处输入图片说明

Note it doesn't automatically update the branch the original PR was merged into it. 请注意,它不会自动更新原始PR合并到的分支。 It creates a new branch with a commit that reverts the PR: 它使用提交来还原PR来创建一个新分支:

在此处输入图片说明

You then can create a PR from this branch and merge it. 然后,您可以从此分支创建PR,并将其合并。

Bitbucket now has the 'Merge Pull Request' feature released. Bitbucket现在发布了“合并拉取请求”功能。 Follow this link to learn more. 点击此链接以了解更多信息。

With bitbucket, we can't revert a merged pull request.使用 bitbucket,我们无法恢复合并的拉取请求。 The revert option which is present in the pull request will create a new branch with a new head(before this commit).拉取请求中存在的还原选项将创建一个带有新头的新分支(在此提交之前)。 That branch later you have to merge into your master/release branch.该分支稍后您必须合并到您的主/发布分支​​。 This is all as communicated by the official Bitbucket doc .这一切都由官方Bitbucket doc传达。 在此处输入图片说明

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

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