What Does "origin" Mean in Git?

Everytime you clone a repository, git, by default (and by convention), creates a local alias called "origin" that points to the remote repository URL that you cloned from. These local aliases are referred to as "remotes" or "remote name". You can find out which remote points to which URL by using the following command:

git remote -v

You can also use the following command to show more information about a remote:

git remote show origin

Please note that you don't have to use the remote name if you don't want to. Instead you could simply use the repository URL directly. However, using a remote name is much more convenient as you don't have to remember, or type the entire URL each time.

It is also worth mentioning that you can easily change the remote name to anything you want. In the following example for instance, the remote name "origin" would be renamed to "foo":

git remote rename origin foo

You can also add a remote name yourself in the following way:

git remote add origin [email protected]:USERNAME/REPOSITORY-NAME.git

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.