Picture of Michael Lee
:wave: Hey hey, I'm Michael Lee! This is my site about being a developer, a dad and a maker.

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 https://github.com/user/repo.git

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  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)
Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design and side projects. Sign up and I'll send you my articles straight to your email.