How to add a remote repository in git

Written on April 21, 2016

Perhaps you’ve already got a project folder, and initiated git on the project with git init. And let’s say you have an existing remote git repository for your project that you would like to use version your project. You can add the remote repository by using the git remote add command.

The remote add command takes two arguments. The first is a remote name, such as origin and the second argument is a URL for the remote repository. Putting it altogether, the command looks like this:

# This sets a new remote to the current git repo
git remote add origin

Once you set a new remote repository, you can verify that the remote was added correctly by running:

git remote -v
# This should yield something like this:
origin (fetch)
origin (push)

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming and side projects with you. Sign up and I'll send you my articles straight to your email, you'll also get a free copy of the light themed version of my Git cheat sheet.
Git cheat sheet preview image