简体   繁体   中英

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?

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 .

You can change the branch on the remote that your branch is tracking by:

git branch --set-upstream   branch_name   your_remote/other_branch_name

This way, pushes of branch_name to your_remote will be done to other_branch_name .

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