1

There is a repository say "A". Now I am creating a new repository by manually moving the code from "A" with some minor modifications and calling it "B". Now, whenever there is a PR from any developers to repo "A" which might be applicable to "B" as well, we need a similar PR to "B". Instead of creating a PR by manually copying the changes from the PRs manually, how can we automate this process?

I am thinking of a webhook based solution. Lets say a PR called PR1 is raised towards repo "A", a webhook can be triggered and processed. However, i need to know i) Is it possible to copy the changes of PR1 to another PR towards repo "B" programattically?

I expect any help raising a new PR to repo B programmatically in Java with the changes coming in a PR to repo A.

Divakar
  • 21
  • 3

1 Answers1

0

Is it possible to copy the changes of PR1 to another PR towards repo "B" programattically?

In theory, yes:

  • you can add A as a remote for B

    git remote add A /url/to/A
    
  • you can A and its PR branch, assuming PR1 was created from A/master

  • you can rebase only commits from that PR onto a new local branch

    git checkout -b newPR
    git rebase --onto newPR $(git merge-base A/master PR1) PR1
    

The idea is to replay those commits on top of your new branch in B.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • you can A and its PR branch, assuming PR1 was created from A/master. --> Can you correct this line VonC? Do you mean i should add A's PR Branch as a remote? – Divakar Jul 10 '19 at 03:15
  • @Divakar A as a remote then fetch: you will get A PR branch in B. – VonC Jul 10 '19 at 04:38