Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 900
RNA Avatar asked Dec 24 '22 19:12

RNA


1 Answers

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 
like image 125
RNA Avatar answered Dec 26 '22 11:12

RNA