Skip to main content

Explore your training options in 10 minutes

Git Add Remote: A Beginner’s Guide

James Gallagher - December 29, 2020

How to Add a Remote to a Git Repository

Have you just started a new Git repository on your local machine? You’ll need to add a remote if you intend on linking it to a remote repository.

The git remote add command adds a remote to a Git repository. In this guide, we’re going to talk about what remotes are, how they work, and how you can add a remote to a repository. Without further ado, let’s begin!

What is a Git Remote?

A Git remote is a connection to another repository.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses

By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

When you set a remote, you can push code to and pull code from a remote repository. A remote repository could be hosted on GitHub, BitBucket, GitLab, or another version control platform.

Remotes are an essential part of the Git system. Git is distributed, which means that many different developers can have their own copy of a project. They can work on a project on their local computers without changing the main version of the project.

Once a developer has finished making changes to a repository, they can push it to the remote version. This will make their code accessible to all the collaborators on a project.

The git remote add Command

You can use git remote add to add a remote to a Git repository. This Git command is commonly run after you have cloned a repository or when you are creating a new repository.

Let’s initialize a new local repository on our machine. We’ll create a new Git repository, make a file, and commit that file to the repository.

git init
cat "# demo-repository" >
git commit -m "docs: Create"

Our repository has one commit. Before we can push this repository to another source, we will need to add a new remote repo:

git remote add origin

This creates a reference to a repository hosted on GitHub called demo-repository. The name of our reference is “origin”. “origin” is the standard label used to refer to the main version of a project. You can set the name of your reference to be whatever you want.

We can check that our remote has been set using the git remote -v command:

git remote -v 

> origin (fetch)
> origin (push)

There are two lines of code in our remote record. When we go run git pull , git fetch , git config, git push , or any other Git command, it will refer to our remote repository called demo-repository.

Error: “fatal: remote origin already exists”

git remote add origin

> fatal: remote origin already exists

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

You may have encountered an error “fatal: remote origin already exists” when running the above command. What’s the problem?

This error is raised when you try to assign a name to a remote that has already been used inside a local version of a repository.

You can resolve this error by using a different name for your new remote. If you are comfortable modifying your existing remote, you can rename or delete the existing remote to free up the name for your new remote.


The git remote add command allows you to add a remote to a Git repository.

If you encounter a “fatal” error when running the command, you should choose a name for your new remote or rename or delete the existing remote with the name you want to use.

Now you’re ready to start using the git remote add command line operation like an expert!

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse,, Afrotech, and others.

Skip to main content