问题
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