Git

List of Remotes for a Git Repository?

While working on Git, developers need to connect the Git local repository with the Git remote repository for collaboration between other project members. For this particular purpose, the “remote” command can be used, which helps developers to manage connections to remote repositories. Additionally, they can view the list of all existing remotes and names.

This post will discusses:

So, let’s begin and go through them one by one!

How to View the Remotes List for a Git Repository?

To view the list of remotes for a Git repository, execute the “git remote” command with the “-v” option:

$ git remote -v

 
As you can see, it will display all existing remote connections for a Git repository:

How to View the Name of Existing Remotes for a Git Repository?

To view the name of all existing remotes for a Git repository, run the simple “git remote” command:

$ git remote

 

How to Add the New Remote for a Git Local Repository?

If you want to add a new remote for tracking a Git repository, write out the following command:

$ git remote add beta https://github.com/GitUser0422/Test_repo.git

 

After adding a new remote URL, execute the “git remote” command with the “-v” option to view and verify the performed operation:

$ git remote -v

 
As you can see in the below-provided output, the new remote URL is added successfully to the list:


Lastly, run the “git remote” command to check the name of the newly added remote URL in the list:

$ git remote

 

We have explained the method to view the list of the remotes and names, and how to add them.

Conclusion

To list the remotes for a Git repository, execute the “$ git remote -v” command. If you want to display the name of all existing remotes, the “$ git remote” command is useful. To add a new remote URL to the list, run the “$ git remote add <origin-name> <remote-url>” command. This post described the method to view the list of remotes and names and how to add them.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.