简体   繁体   中英

Git push different branches to different remote repos?

How can I push two branches of the same project to different repos on github?

I have two branches locally:

  • master
  • develop

On master I have a "coming soon" page that deploys to Github pages and in the meanwhile I work on develop locally.

But now I want to have a preview of "develop" on a different GitHub page, so i thought the best way of doing so would be to push only that branch to a different repo. Is that possible?

Thanks,

Matteo

You can push and fetch anything you want anywhere you've got the access. Just do it: add a remote for the other repo, call it "preview" or something, and git push preview develop . If you also want that history in the original, push it there too.

I don't think you can push one branch to separate repo. You can do either of these things.

  1. Either you create a separate project for develop branch and push to a new repo
  2. Or You can push master to Repo1, then change remote of your project using

    git remote set-url origin new_url

then push your develop, But this will also push your master - You will have to separately remove that

  1. IF both the branches are linked, I don't think you need a separate Git repo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM