Join my Laravel for REST API's course on Udemy 👀

Adding remotes to your git repository

June 6, 2022  ‐ 1 min read

When we clone a git repository, from GitHub for example, the origin remote is set up automatically for us.

But if you wish to add a second remote to your git repository, or when you created a local repository instead of cloning we can add a remote manually.

For this we need the following command:

$ git remote add <remote name> <remote url>

Let's for example add a second remote called upstream to a forked repository:

$ git remote add upstream git@github.com:getzola/zola.git

To validate whether the remote was added correctly we can review the output of the git remote -v command:

$ git remote -v
origin  git@github.com:koenwoortman/zola.git (fetch)
origin  git@github.com:koenwoortman/zola.git (push)
upstream        git@github.com:getzola/zola.git (fetch)
upstream        git@github.com:getzola/zola.git (push)