How do I change the URI (URL) for a remote Git repository?

15    Asked by Ankityadav in Devops , Asked on Apr 16, 2025

Need to update your Git remote URL after switching platforms or accounts? Learn how to quickly change the remote repository URI so you can push and pull code from the right location without any hiccups.

Answered by James Wilson

Changing the URI (or URL) for a remote Git repository is a pretty common task—especially if you’ve moved your repo to a different Git hosting service (like from GitHub to GitLab) or switched from HTTPS to SSH. Luckily, it’s super easy to update.

Here’s how you can do it:

  •  Check your current remote URL
  • You can view your current remote using:

  git remote -v

  •  Change the remote URL
  • To update the remote URL (usually named origin), use:

  git remote set-url origin 

Replace with your new repository link, whether it's an SSH or HTTPS URL.

 Verify the change

After updating, check it again:

  git remote -v

This should now show your updated URL.

 Example:

Let’s say you’re switching from HTTPS to SSH:

  git remote set-url origin git@github.com:yourusername/your-repo.git

 Why this matters:

  • Keeps your Git setup in sync with the correct remote repository.
  • Avoids errors like repository not found or permission denied.



Your Answer

Interviews

Parent Categories