Search code examples
gitgit-remote

How to: push in repo A, pull from repo B, then push from A to B


I have two branches (Mine and Other) in two remote repositories. I'm planning to push into Mine and pull from Other to get updates. No pushes to Other at that time. Then, at some point, I want to push everything that has been pushed to Mine into Other. How can I do that?

I was thinking that I need to clone Other, add Mine as a remote, and push/pull with specific remotes.

The thing I don't know how to do is: how to push all commits from Mine to Other later in time?

enter image description here

And if that's not possible with different branches, will it be possible with one branch, but in different remotes? By “different” branches I mean that they have completely different code, there are no common commits and I want to push to the branch Other only several commits from the branch Mine?


Solution

  • It seems you are describing a push request flow. Anyway yes, your plan should work. Setting the default for pushing on Mine repos could be helpful

    $ git push -u Mine <branch_name>
    

    Later when want to update Other as well simply

    $ git push Other <branch_name>
    

    should push all commits in <branch_name>... it's git push job...