Aug 102018

ADM

How to add a remote to git

  • August 10 2018
  • ADM

 

 

How to add a remote to git - git

 

To add a remote you can use the command git remote add in the terminal, from the root folder of your repository.

The git remote add command has two parameters:

  • the remote name, the most used name is origin, but if you have multiple repositories to push more suggestive names are recommended. I will go with gitlab
  • the remote URL, for example, https://gitlab.com/admfactory/jersey-hello-world.git

Add

C:\Users\adm\repos\jersey-hello-world>git remote add gitlab https://gitlab.com/admfactory/jersey-hello-world.git

To check the remote run the following command:

C:\Users\adm\repos\jersey-hello-world>git remote -v
gitlab  https://gitlab.com/admfactory/jersey-hello-world.git (fetch)
gitlab  https://gitlab.com/admfactory/jersey-hello-world.git (push)
origin  https://github.com/admfactory/jersey-hello-world.git (fetch)
origin  https://github.com/admfactory/jersey-hello-world.git (push)

Errors

if the remote is already present the following error will occur:

C:\Users\adm\repos\jersey-hello-world>git remote add gitlab https://gitlab.com/admfactory/jersey-hello-world.git
fatal: remote gitlab already exists.

References