Project Initiator – Link Between Remote and Local Repositories (git remote add)

How to Link Your Local and Remote Repositories with git remote add

To upload your code from your Local Repository to your Remote Repository, first, you need to connect your Local Repository to your Remote Repository. git remote add is the command used to establish the connection.

For the command, you need to specify the URL of your Remote Repository. There are different URLs for different communication protocols. You can choose HTTPS or SSH.

HTTPS
Link Between Remote and Local Repositories with HTTPS
SSH
Link Between Remote and Local Repositories with SSH

The URL structures are like in the examples below. The initial parts of URLs are different. However, the latter parts are the same: GitHub Account Name and Remote Repository Name. origin is the default remote Repository name.

  • HTTPS: https://github.com/GitHub Account Name/Remote Repository Name.git
  • SSH: git@github.com:GitHub Account Name/Remote Repository Name.git

You can check the Remote Repository URL setting status by running the git remote -v.


Note: There are other git remote commands, which will be explained on this topic page Link With Remote Repository – Git Remote.


We have included an integrated practice section later in this chapter to cover creating a new repository, uploading project documents, and inviting a project member to the repository. Go to Project Initiator – Grant Remote Repository Access to Project Members for the practice.