Doing git-push without origin master

前端 未结 3 814
無奈伤痛
無奈伤痛 2020-12-17 21:05

Is there a way on GIT to just do a \"git push\" and it automatically send to \"origin master\" without specify that? Just curious...

相关标签:
3条回答
  • 2020-12-17 21:29

    Your master branch should be automatically setup so this works. If you are on some other branch, then you can use the git branch command with the --set-upstream option

    git branch --set-upstream someBranch origin/master
    

    It might be also the case that you don't have a remote set, in the case when you have a bare and clean repository setup waiting for you to push to it for the first time, e.g. when you are setting up a repo on github. Assuming you have setup your remote you can push to the server with the -u option that will take care of the branch --set-upstream for you:

    git push -u origin master
    

    which is the same as:

    git push origin master
    git branch --set-upstream master origin/master
    
    0 讨论(0)
  • 2020-12-17 21:38

    git push already does git push origin master when you are in master.

    git push
    

    Works like git push <remote>, where <remote> is the current branch’s remote (or origin, if no remote is configured for the current branch).

    http://www.kernel.org/pub/software/scm/git/docs/git-push.html

    0 讨论(0)
  • 2020-12-17 21:50

    The default behaviour is defined by the push.default configuration setting.

    If you do a search for push.default on http://git-scm.com/docs/git-config you'll find an explanation for its various options.

    0 讨论(0)
提交回复
热议问题