5

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!

6
  • Are A and B on different servers, or just under different owners on the same github server? I'd approach this by creating your own fork of A, and having A-fork + B as two remotes in the same sandbox to push the B changes to A-fork and then do a PR from A-fork to A. But you're saying you can't fork, why is that anyway?
    – joanis
    Commented Jul 17, 2019 at 18:15
  • @joanis I don't own the organization of either a or b, or the repo itself. Repo b I'm admin with write access, repo A I have read only access
    – unixandria
    Commented Jul 17, 2019 at 18:38
  • But are they on the same server or not? If not, and if you can't fork from A, I don't see how you could possibly do a PR to A... PR's are not a Git thing proper, they're a server software thing, so they have to be supported by the destination server.
    – joanis
    Commented Jul 17, 2019 at 18:54
  • @joanis it's GitHub
    – unixandria
    Commented Jul 17, 2019 at 19:23
  • If it's GitHub, just fork A: as soon as you have read access to a repo, you should be able to fork it, push your changes to your fork, and create the pull request there. You don't need to be owner or admin to fork, read access is enough.
    – joanis
    Commented Jul 17, 2019 at 22:29

2 Answers 2

5

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.

7
  • Any git push results in access denied though...at least any I've tried....
    – unixandria
    Commented Jul 18, 2019 at 2:07
  • Oh wait a-fork nvm
    – unixandria
    Commented Jul 18, 2019 at 2:07
  • When you create a fork, you own that fork, you should have write access to it. Make sure you're using the right credentials to push with.
    – joanis
    Commented Jul 18, 2019 at 2:08
  • It's telling me everything is up to date when I push to a-fork when it should be 5 commit behind
    – unixandria
    Commented Jul 18, 2019 at 2:14
  • Did branch-for-PR exist on A before?
    – joanis
    Commented Jul 18, 2019 at 2:16
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.