I mused on this:
When using git, I occasionally want to do one of two things:
- Delete a remote repo
- Push a local branch to a different remote branch
Deleting remote branches panders to my penchant for keeping things tidy. Pushing branches to a different remote branches is useful for deploying a staging branch, for example, to heroku, without merging to the master branch.
It's all in the ":"
git push allows you to specify a source and target branch by using a ":" to separate them.
Normally, something like "git push heroku master" will push the current local master branch to the remote master branch on the remote heroku repo.
If you add a ":" eg. "git push heroku :master", you change the command to pushing nothing to the remote master branch. That is to say, delete the remote branch: git doesn't do empty branches or folders.
Following from that, if you want to push to a different remote branch, "git push heroku staging:master" will push the current local staging branch to the remote heroku master branch. At this point, feel free to sit back with a big cheeky grin.