unixandria
unixandria

Reputation: 282

Git pull request from different repo on different org

Ok I have a possibly unique situation

I have two repository, in different organizations (B is not a fork of A but a clone), but both on GitHub. One I'm an admin of (B), the other I'm a collaborator with read access only (A).

To be clear, I am owner of neither so I can't delete and fork instead.

I need to submit a pull request from repository B to repository A. Is this even possible? If so, how!

Upvotes: 5

Views: 3354

Answers (2)

joanis
joanis

Reputation: 12280

Based on the clarifications in the comments, here is a complete solution that should work for you:

Step 1. Go to GitHub and fork A to create A-fork.

Step 2. Clone your fork:

git clone <URL for A-fork>

Step 3. Add B as a second remote to the same sandbox and checkout the branch you have to submit as a Pull Request - I'll call it branch-for-PR:

git remote add B <URL for B>
git fetch B
git checkout branch-for-PR

Step 3 b. If branch-for-PR already existed on A-fork, you'll need to merge the state of that branch from B:

git merge B/branch-for-PR

Step 4. Push the branch-for-PR to A-fork, which is origin since that's what you cloned in step 2:

git push origin branch-for-PR

Step 5. Go to A-fork on GitHub and create a pull request from branch-for-PR. That will notify A's administrators as usual.

This would work regardless of where B was hosted, on a private Git repo or under another GitHub user. All you need is to be able to connect to both from the same sandbox.

Upvotes: 5

mgershen
mgershen

Reputation: 1677

Yes. As long as they share the enough history (commits), there is no problem.

  1. go to the B directory and add A as a remote (git remote add repoA $GIT_REPO_URL).
  2. git fetch repoA
  3. continue the same way you would have if one was a fork of the other

Upvotes: 1

Related Questions