Scooby
Scooby

Reputation: 3581

How can I push a branch into a separate remote repo?

I have a local repo A, with only one branch (master) and a remote repo B. Each of those repos has its own history.

I want to push repo A's master branch to a new branch called branch1 in repo B. How can I do that?

Upvotes: 0

Views: 147

Answers (1)

jub0bs
jub0bs

Reputation: 66193

If you want to push your master branch on the (local) repo A to a new branch called branch1 on a (remote) repo B, you need to

  1. Make sure that B is listed as a remote repository for repository A at at the correc URL: while within repo A, run

    git remote -v
    

    If you don't see the URL corresponding to repo B in the list, you need to add repo B as a remote for repository A, using

    git remote add <remote-name> <url>
    

    In the following, I'll assume that repository B is listed as a remote for repo A under the remote name repoB.

  2. Do the push: while within repo A, run

    git push repoB master:branch1
    

Upvotes: 2

Related Questions