Say I added a new remote repo under my project folder by:
git remote add origin2 ADDRESS_OF_NEW_REMOTE_REPO
then, I start to push my code to my new remote repo. Locally, my branch name is "develop", I want to push to my new remote repo with a different branch name, say "production", can I simply do this by command:
git push origin2 production
though locally, I am under branch "develop" ? What is the correct way to do this? and what potential problems could be caused by doing this?
$ git push yourremotename local_branch:remote_branch
(yourremotename here is remote name, often "origin", "github", "heroku" or similar)
So for you something like:
$ git push origin2 develop:production
For the most cases I think I would just rename the local branch to avoid confusion, if it's possible.
$ git branch -m develop production
This way it is easier to keep track as to what branch references which.
I understand though that for example Heroku would only deploy from master branch, so sometimes you do want to have the names separate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With