Can cherrypick all PR(pull request) from github?

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 ;)


git remote add



Thanks in advance





I don't think that a PR in GitHub (or any other Git repo provider) can have more than a single repo/branch destination. It sounds like your workflow is a mess, from what I read above.
– Tim Biegeleisen
Mar 23 '17 at 6:12





@TimBiegeleisen, How can I improve my workflow? Please guide me
– RNA
Mar 24 '17 at 2:45





Why do you have so many forked respositories?
– Tim Biegeleisen
Mar 24 '17 at 2:46




3 Answers
3



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



add pr/* to .git/config


test_repo


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


vim .git/config


[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


$ 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


git cherry-pick test_repo/pr/xx



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


pull


PR-branch



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:


PR#65


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





Use git fetch, not git pull, here, as git pull will git merge the pull request commit but the goal is to cherry pick rather than merging. (In general I commend not using git pull at all.)
– torek
Mar 23 '17 at 11:35


git fetch


git pull


git pull


git merge


git pull





That technically true @torek. But since the OP is looking for easier/shorter way to have the PR commit(s) within the source code, git pull is the way to go as it will fetch the PR branch and merge all the commits in the PR in one go.
– ashmaroli
Mar 23 '17 at 12:44


git pull


fetch


merge





That's the thing: he said, rather clearly, that he did not want them merged.
– torek
Mar 23 '17 at 13:03






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Help:Category

How can temperature be calculated given relative humidity and dew point?

I have a recursive function to validate tree graph and need a return condition