1

I find it interesting that the remote branch name to be used when pushing back to the remote git repository is named "origin" when it's actually called "master"... Why is this the case?

3
  • 3
    Actually, it is origin/master. Commented May 21, 2018 at 21:19
  • 1
    Origin refers to the remote server, not the branch. You can have multiple remotes set up for the same local repository. Origin is the default name for the one that the repo was cloned from. Commented May 21, 2018 at 21:19
  • 1
    Also worth remembering: the Git on the remote, i.e., the Git that you call origin, is a Git repository. It has its own branches, including its master. What you call origin/master is your Git's way of remembering their master, which they just call master. (They have no name for your master as they have no need to remember that you even exist :-) .) Commented May 21, 2018 at 21:47

2 Answers 2

7

master is the name of a branch. origin is the name of a remote. A remote is a complete git repository that may contain many symbolic branch names; you're generally trying to push your commits from your local master to the remote's - origin/master in this case.

Sign up to request clarification or add additional context in comments.

Comments

3

The main advantage for origin, which reference where to push, is that it is the default name for a remote repository reference.

So your first push of your local master branch should be:

git push -u origin master 

(See "Why do I need to explicitly push a new branch?")

But after that, master is linked to origin/master, and a simple git push will be enough, which defaults to git push origin (git push to origin the current branch)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.