在本地检查bitbucket pull请求

moy*_*260 29 bitbucket

我找到了这个要点:https: //gist.github.com/kennethreitz/3709868

我正在使用bitbucket,我正在寻找类似的功能.

你能帮助我吗?谢谢

Duc*_*035 16

可以使用以下方法从Bitbucket Server的pull请求中获取代码:

git fetch origin refs/pull-requests/$PR_NO/from:$LOCAL_BRANCH
Run Code Online (Sandbox Code Playgroud)

  • 这不起作用.它给出了以下错误,'致命:找不到远程引用refs/pull-requests/2/from``Unexpected end of command stream`. (5认同)

zmo*_*zmo 15

我找到了这个答案,并认为实际上可以获取bitbucket上的pull请求的refs.

但事实并非如此.

对于OP的问题的答案是,这是不可能的:还有的是关于它的开放功能请求的问题是一直无人接听,无人值守的4 5 SIX年.

解决方法?

您可以将PR作为可下载的.patch可下载文件获取并应用于您手动创建的新分支.但是您无法轻松应用更新.

我想出了另一条出路,我已经在git-repo中实现,所以每个人都可以使用它.我正在做的是使用API​​来获取PR的远程和分支,并自动在本地创建新的上游和分支.这样你就可以从PR海报上获得更新.缺点是git遥控器的混乱.

  • 我可以成功下载运行以下命令的补丁:`#下载补丁文件.curl -u user:password https://bitbucket.org/api/2.0/repositories/{user}/{repo}/pullrequests/{pull_no}/patch -L -o name.patch#将补丁文件应用到本地Git结账.git apply name.patch` (2认同)

Ale*_*dan 8

Fetch/Checkout Pull Requests

This works for bitbucket. Other server could have different refs: (refspecs) or no refs: at all.

First Time

First of all you need to add the pull request refs: of the remote repository. To do that to a repository (e.g. aliased 'upstream'):

git config --add remote.upstream.fetch '+refs/pull-requests/*/from:refs/remotes/upstream/pull-requests/*'
Run Code Online (Sandbox Code Playgroud)

That is, you add the last line on git .config file:

[remote "origin"]
   url = ssh://git@git.blablabla.net/~user/repository.git
   fetch = +refs/heads/*:refs/remotes/origin/*
   fetch = +refs/pull/*/head:refs/remotes/origin/pull-requests/*
Run Code Online (Sandbox Code Playgroud)

Fetching

Then if you perform the remote fetch you should see the retrieval of (also) all the pull requests:

git fetch upstream

From ssh://git.blablabla.net/somepath/repository
 * [new ref]         refs/pull-requests/1188/from -> upstream/pull-requests/1188
 * [new ref]         refs/pull-requests/1741/from -> upstream/pull-requests/1741
 * [new ref]         refs/pull-requests/2394/from -> upstream/pull-requests/2394
Run Code Online (Sandbox Code Playgroud)

Checking out

Finally you can checkout the pull-request you prefer:

git checkout pull-requests/2723
Run Code Online (Sandbox Code Playgroud)

Successfully tested on dedicated bitbucket server 27/02/19.

  • 太棒了@alex-gidan!完美地工作。这将是我在 2019 年使用兼容版本的 bitbucket 回答的首选。: 竖起大拇指: (3认同)
  • @bkidd 我同意,让这个答案直接进入前 8 名) (2认同)

小智 7

我遵循了这篇文章Pull request Fetching

它起作用了,但是我发现我只需要在当前仓库中添加一行,而不是创建一个民间仓库和一个上游仓库。运行这条线

git config --add remote.origin.fetch '+refs/pull-requests/*/from:refs/remotes/origin/pr/*'

您也可以将其手动添加到项目中的.git / config文件中。

下次运行时,git pull您应该会看到一个列表:

  • [新裁判]裁判/拉取请求/ 488 /从->起点/ PR / 488
  • [新裁判]裁判/拉动要求/ 666 /从->起点/ PR / 666

然后,您可以运行git checkout origin/pr/666以获取拉取请求更改。