Search code examples
gitgithubgit-push

Pushing from local master to a remote non-master branch


On my local machine, I have a repository set up as the following

* remote origin
  Fetch URL: git@github.com:me/my_project.git
  Push  URL: git@github.com:me/my_project.git
  HEAD branch: master
  Remote branches:
    mac-master tracked
    master     tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

There is only master branch locally, and I want to always push my local master to the remote mac-master branch. Should I just do:

git push origin master:mac-master

every time I need to push? If not, what is the correct way of doing it?


Solution

  • If you always want to do it, run

    $ git push -u remote master:mac-master
    

    once. The -u flag will set up options so that subsequently you can do:

    $ git push
    

    to push master to mac-master on remote.