Doing git-push without origin master

你说的曾经没有我的故事 提交于 2019-12-10 02:36:50

问题


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


回答1:


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



回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/6074009/doing-git-push-without-origin-master

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!