To change the URI (URL) for a remote Git repository, you can use the git remote set-url command. Here's how you can do it:
Step 1: List Current Remote URLs
First, you may want to see the current URLs associated with your remote repository:
This command will list the names and URLs of all remote repositories. You'll see something like this:
Step 2: Change the URL
To change the URL of the remote repository, use the git remote set-url command followed by the remote name (e.g., origin) and the new URL:
Replace <new-URL> with the new URL of the remote repository.
Step 3: Verify the Change
You can verify that the URL has been changed by listing the remote URLs again:
The new URL should now be displayed.
Note:
- You can also use this command to change the URL for a different remote repository by specifying its name instead of
origin. - Ensure that you have the necessary permissions to push to the new URL if you intend to push changes to the repository.
- Changing the URL does not affect the commits or branches in the repository; it only updates the location from which you fetch and push changes.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.