YCode YCode - 1 year ago 80
Git Question

What is the difference between 'origin' and 'remote' in git commands?

In git lingo, are

the same thing? Or does
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!

Answer Source

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

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

All remotes are equal. origin is simply (and literally) the first among those equals (for a cloned repo). :)

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 identified by the (locally configured) name origin.

If there is no master branch in the remote then one will be created.

Full details of the push command and the flags, options etc are of course in the docs.

You rarely (if ever) refer to the 'local' repo explicitly since your operations are performed in the context of a repo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download