可以从github樱桃挑选所有PR(拉动请求)吗?

时间:2017-03-23 06:08:05

标签: git github pull-request cherry-pick git-cherry-pick

是否可以从github中挑选所有待处理的PR?

假设我有来自4个不同分叉存储库的4个PR等待审核。我需要将它们全部应用到最新的源代码中。

PR#65 Do something
PR#61 Notify this
PR#55 Fix that
PR#42 Show there

我知道我可以git remote add所有存储库并逐个挑选它们。但是,我相信会有更简单/更短的方式挑选所有未决的拉动请求,我还不知道;)

提前致谢

3 个答案:

答案 0 :(得分:5)

简而言之:

将pr / *添加到.git / config

详细说明:

假设存储库名为test_repo

$ git remote -v
test_repo     http://github/testA.git (fetch)
test_repo     http://github/testA.git (push)

1。打开git config

vim .git/config

2。在[remote "test_repo"]

下添加以下行
fetch = +refs/pull/*/head:refs/remotes/test_repo/pr/*

所以它看起来像

[remote "test_repo"]
url = http://github/testA.git
fetch = +refs/heads/*:refs/remotes/test_repo/*
fetch = +refs/pull/*/head:refs/remotes/test_repo/pr/*  <-- this line was added

3。 &#34; git fetch&#34;也将获取PR

$ git fetch test_repo

 * [new ref]         refs/pull/16/head -> test_repo/pr/16
 * [new ref]         refs/pull/17/head -> test_repo/pr/17
 * [new ref]         refs/pull/18/head -> test_repo/pr/18
 * [new ref]         refs/pull/19/head -> test_repo/pr/19

4。现在你可以樱桃挑选/结帐到PR #xx

git cherry-pick test_repo/pr/xx 

答案 1 :(得分:4)

您无法提交提交,因为提交不在您的本地存储库中。

你应该像那样获取拉动请求..

1乘1: https://help.github.com/articles/checking-out-pull-requests-locally/

一下子: https://gist.github.com/piscisaureus/3342247

答案 2 :(得分:1)

您需要做的是pull逐个PR-branch,根据需要解决冲突。

假设:

  - PR#65 at https://github.com/author_1/your-repo/tree/PR-branch-name-1
  - PR#61 at https://github.com/author_2/your-repo/tree/PR-branch-name-2
  - PR#55 at https://github.com/author_3/your-repo/tree/PR-branch-name-3
  - PR#42 at https://github.com/author_4/your-repo/tree/PR-branch-name-4

然后在本地拉出每个PR:
例如PR#65

git checkout <your-test-branch>
git pull https://github.com/author_1/your-repo.git PR-branch-name-1