I have a setup with two servers (staging and production). Both of these has a master branch I can push to (I use heroku, not that it matters though).
Currently, I can push to staging with this command:
git push staging master
Which will push my local master branch. However, I would like to have a local branch named staging, which will push to the remote repository staging/master. How can this be done?
To do it manually,
I’d suggest maybe setting up a configuration that would allow you to do it automatically, though:
which tells git to push the local
stagingbranch tomasteron the remote side (i.e. the staging remote) (if I remember the syntax correctly), and optionallywhich will tell git that if you have
stagingchecked out and just typegit push, it should push to thestagingremote.Of course I think you can do this using
git branchandgit remote, but I just went through the process of creating a similar setup (2 servers) and I found it easier to just work with the configurations directly.