skip to content
some test image
Omar Gaxiola

Verify The Git Remote URL For Your Project

/ 2 min read

Last Updated:

Tutorial: How to Manage Remote Repositories with Git

In this tutorial, you will learn how to check the remote URL of your Git repository, as well as how to add and remove a remote repository.

Check the Remote URL

To see which remote repository your Git project is pointing to, you can use the following command:

Terminal window
git remote -v

This command will show you something like the following:

origin https://github.com/user/repository.git (fetch)
origin https://github.com/user/repository.git (push)

Remove a Remote Repository

If you want to remove a remote repository (e.g., origin), you can use the following command:

Terminal window
git remote remove origin

This will remove the reference to the remote repository named origin.

Add a New Remote Repository

To add a new remote repository, use the following command:

Terminal window
git remote add origin <URL-of-the-new-repository>

Replace <URL-of-the-new-repository> with the URL of the new repository you want to point to. For example:

Terminal window
git remote add origin https://github.com/user/new-repository.git

Complete Example

Here is a complete example of how to check, remove, and add a remote repository:

  1. Check the Remote URL:

    Terminal window
    git remote -v

    Expected output:

    origin https://github.com/user/repository.git (fetch)
    origin https://github.com/user/repository.git (push)
  2. Remove the Current Remote Repository:

    Terminal window
    git remote remove origin
  3. Add a New Remote Repository:

    Terminal window
    git remote add origin https://github.com/user/new-repository.git
  4. Check the New Remote URL:

    Terminal window
    git remote -v

    Expected output:

    origin https://github.com/user/new-repository.git (fetch)
    origin https://github.com/user/new-repository.git (push)

And that’s it! Now you know how to manage your remote repository URLs in Git.