How do I change Git remote URL?
You can use the git remote
set-url command to change the URL of your remote. First, you will need to open Terminal (if using Mac or Linux) or the command prompt (if using Windows).
- Locate your project on your local computer. You can do this by running:
Then check and confirm a list of all of your existing remotes. To do this run this command:
For example, the output may look like something like this:
This list will contain your existing remote names and URLs.
1. Change the URL of the remote with the git remote set-url command:
git remote set-url origin firstname.lastname@example.org:/your-repository.git
This command tells git to change the URL for the remote, “origin” to be something different.
For example: Let’s say you want to change your remote URL to be connect via SSH instead of HTTPS. You can tell git to set a new URL for the remote. In this example, we want to change our remote URL from:
To make this change, the command we’ll run will look like this:
Once done, you can verify that your remote URL has changed by running:
Now you have successfully changed your remote URL.