Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

In git lingo, are origin and remote the same thing? Or does origin refer to the local directory?

In the case of git push -u origin master: Which of the following interpretation is correct?

  1. "push everything upstream to the remote repo called 'origin' and its branch 'master'"
  2. "push everything from the local originating repo called 'origin' to the upstream 'master' branch"

Appreciate any clarification!

The answers to my question clarified two issues for me:

  1. origin refers to the remote repo, rather than the locally cloned copy of the remote repo. This is not clear when one reads that origin is an alias of remote and is created at the time of git clone
  2. origin refers to the remote repo in git push -u origin master because local copies of the repo are implied and "rarely referenced".

1 Answer

+1 vote
by (62.9k points)

In git lingo origin is simply the default name for a remote from which a repo was originally cloned. It might equally have been referred to as source or remote1 or simply remote.

Remember that git could be a peer-to-peer, distributed system, not one with any built-in notion of client/server, master/slave, parent/child relationships (though these could be obligatory upon it by a user in a particular scenario).

All remotes are equal. origin is solely (and literally) the primary among those equals (for a cloned repo).

The name associated with each remote is intended for your convenience. If you discover that origin doesn't really work for you then you can change it.

As for your interpretations of the push statement, your first is the closest to being correct but the push command as written will push the local master branch to the master branch on the remote known by the (locally configured) name origin.

If there's no master branch within the remote then one will be created.

by (19.7k points)
Got it, thanks for the answer!

Browse Categories

...