What Is ‘origin’ in Git: A Complete Guide

In Git, origin is convenient shorthand alias for the URL of the remote repository.

Notice that there’s nothing special about the name “origin“. You could change the origin to anything else that makes sense.

You have probably seen a command like git push origin main. This means pushing the changes to the remote repository.

This comprehensive guide teaches you what is the “origin” in Git and why such a naming convention exists. You will also learn how to rename “origin” to something else.

What Is Origin in Git?

By using a shorthand notation like “origin”, the developer doesn’t have to type out the entire remote repository URL when making a change.

If you have an example repo you’re working on, you can check what the origin is an alias for. To do this, run:

git remote -v

For example, in my case, it’s an alias for the following:

As you can tell from the above screenshot, it’s much more convenient to talk about “origin” instead of https://artturijalli:<my-secret-github-access-token>@github.com/artturijalli/exampleproject.git.

Without origin, a git push to a remote repo would look something like this:

git push https://artturijalli:<my-secret-github-access-token>@github.com/artturijalli/exampleproject.git main

But with the origin as a shorthand, the command simplifies down to this:

git push origin main

Why Origin?

There’s nothing special about the word “origin“. It’s just a default local alias for the remote repository. As stated earlier, using “origin” instead of the entire path to the remote repository makes it easier to operate.

Also, a lot of Git tutorials use “origin” when pushing or fetching changes from the remote repo. So even though you can change the word “origin” to something else, you might find it inconvenient.

How to Rename “Origin”?

Because the name “origin” is just a local naming convention for the remote repository URL, it’s easy to change it. To change “origin” to something else, use the git remote rename command:

$ git remote rename origin <some-other-name>

For example, I’m going to rename “origin” as “source”. To do this, I have to run:

$ git remote rename origin source

Here you can see the action taking place in my Terminal:

Changing the “origin” to “source”.

From this point on, the “origin” no longer refers to the remote repo. Instead, I have to call it “source” from now on. This change is visible in commands, such as git push:

git push source main

To change the name back to “origin“, you can run the same command again by replacing origin with source and vice versa.

For example:

git remote rename source origin

Thanks for reading. Happy coding!

Scroll to Top