What does "master" mean in "git push origin master"

Solution 1:

This is the Master branch. The main tree of your control system.

push = push your changes to the remote server
origin = remote Server origin
master = Master branch

If you have another remote branches you have something like "git push origin test" then you push your changes to the test remote branch.

Solution 2:

That master is the <src> part of a refspec.

This means that your local master branch will be pushed to the master branch of the remote origin (orgin/master).


If you would have specified

git push origin master:my_work

then you would have pushed your local master to origin/my_work. If you don't use the :my_work part, then the destination defaults to the same branch as given as source.


Just specifying

git push origin

will push every local branch that has a matching remote branch to that branch per default. Not just the current branch. This is the same as using git push origin :.

You can change this default with git config remote.origin.push HEAD, which would push the current branch to a remote branch with the same name.

See configure-a-local-branch-for-push-to-specific-branch for further details on configuring refspecs and setting push.default.


Solution 3:

Let me try to explain all elements of this command "in very dumbed-down terms".

git push origin master
  1. git you do something with git :)
  2. push you upload your changes to a remote repo = you update the remote repo with your changes
  3. origin you specify the remote place to push to, usually the particular remote repo where you cloned your directory from
  4. master you specify the branch which you want to push to origin

As a newbie you usually will have only one remote repo (origin) and only one branch (master), so you can use:

git push

simply which means the same as git push origin master in this case.

Check also .git/config in your working directory, it contains info on origin and master.

Tags:

Git