RNA
RNA

Reputation: 1091

Can cherrypick all PR(pull request) from github?

Is it possible to cherry-pick all pending PR from github?

Let's say I have 4 PR from 4 different forked repositories waiting for review. I need to apply all of them to the latest source code.

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

I know that I can git remote add all repositories and cherry-pick them one by one. However, I believe there would be easier/shorter way to cherry-pick all pending pull request which I don't know yet ;)

Thanks in advance

Upvotes: 6

Views: 11563

Answers (3)

RNA
RNA

Reputation: 1091

in short:

add pr/* to .git/config


in detail:

Assume the repository is named test_repo

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

1. open git config

vim .git/config

2. add below line under [remote "test_repo"]

fetch = +refs/pull/*/head:refs/remotes/test_repo/pr/*

so it would look like

[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. "git fetch" will fetch PRs too

$ 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. now you can cherry-pick/checkout to PR #xx

git cherry-pick test_repo/pr/xx 

Upvotes: 6

Philippe
Philippe

Reputation: 31237

You can't cherrypick the commits because the commits are not in your local repository.

You should fetch the pull requests like that..

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

All at once: https://gist.github.com/piscisaureus/3342247

Upvotes: 4

ashmaroli
ashmaroli

Reputation: 5434

What you need to do is pull each PR-branch one-by-one, resolve conflicts as required.

Given:

  - 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

then pull each PR locally:
e.g. the PR#65:

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

Upvotes: 1

Related Questions