I'm new to git as a version control system. I tried reading the documentation, but I don't understand what "master" means in this command:
git push origin master
Can someone explain in very dumbed-down terms?
I'm new to git as a version control system. I tried reading the documentation, but I don't understand what "master" means in this command:
git push origin master
Can someone explain in very dumbed-down terms?
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.
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
.
Let me try to explain all elements of this command "in very dumbed-down terms".
git push origin master
git
you do something with git
:)push
you upload your changes to a remote repo = you update the remote repo with your changesorigin
you specify the remote place to push to, usually the particular remote repo where you cloned your directory frommaster
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
.
git push origin master
The repository is created in GitHub. So it is the origin. So basically our remote repository(or repo on GitHub is know as origin)
Master is nothing but a default branch in our local repo
Pushing the local master branch to the remote origin is what makes that command
git push -u origin master
-u stand for upstream
Using -u is like setting a path for push
So next time we can use 'git push' directly, because now we have set a path for where this push should take the current branch to
git push origin master will push your changes to the remote server. "master" refers to master branch in your repository.
If you want to push your changes to any other branch (say test-branch), you can do it by: git push origin test-branch.
This will push your code to origin of test-branch in your repository.