Link With Remote Repository – Git Remote

Establishing a Link with git remote

git remote is the command used when you want to establish and check the linking status between a Remote Repository and your Local Repository. There are some derivative commands and options for this command. We'll explain five major usages on this page.

Key Git Remote Commands
  • git remote add: Establish a link with a Remote Repository
  • git remote -v: Check the status of the linked Remote Repository
  • git remote rm: Delete the Remote Repository link
  • git remote set-url: Change the Remote Repository URL
  • git remote rename: Change the Remote Repository name

1. git remote add

Establishes a link between a Local Repository and a Remote Repository. As explained before, when you launch a project as the owner of the Remote Repository, you need to upload your project directory to the Remote Repository first. Before pushing the code, you need to establish a link between your Local Repository and the Remote Repository. The command to establish the link is git remote add. You need to specify a Remote Repository name and Remote Repository URL as shown below. The Remote Repository name is typically origin. You can get the URL from the Remote Repository page on GitHub.

git remote add [Remote Repository name] [Remote Repository URL]

2. git remote -v

Checks registered Remote Repositories. After you create a link with a Remote Repository by running the git remote add command or the git clone command, you may want to check the status of the link. git remote -v is the command used to check the status of the Remote Repository linked with your Local Repository. This command doesn't require any argument as shown below.

git remote -v

3. git remote rm

Deletes the Remote Repository link. When you want to deregister the link in the Remote Repository, the git remote rm command is used. To run the command, you need to specify the Remote Repository name as shown below.

git remote rm [Remote Repository name]

4. git remote set-url

Changes the Remote Repository URL. When you want to change an SSH connection to an HTTPS connection or you simply want to change the URL of the Remote Repository, you can run the git remote set-url command. When you run the command, you need to specify the existing Remote Repository name and new URL.

git remote set-url [existing Remote Repository name] [new URL]

5. git remote rename

Changes the Remote Repository name. The typical name of a Remote Repository is origin. However, there may be a situation, such as managing multiple Remote Repositories at the same time, when you want to use different names for the Remote Repositories. You can change the Remote Repository name by running the git remote rename