Derek M. D. Chan
Derek M. D. Chan

Reputation: 565

Why is the remote branch name in git "origin", and not "master"?

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?

Upvotes: 1

Views: 2621

Answers (2)

VonC
VonC

Reputation: 1323183

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)

Upvotes: 3

Carl Norum
Carl Norum

Reputation: 224844

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.

Upvotes: 7

Related Questions