To update the origin
URL of your Git repository (i.e., the remote repository URL), you can use the git remote set-url
command.
Here’s how to do it -
Steps to Update the Origin URL:
Check the Current Remote URL: To see the current URL associated with
origin
, you can rungit remote -v
This will show the current URLs for both fetching and pushing.Update the Remote URL: If you want to change the
origin
URL, you can use the following commandgit remote set-url origin <new-url>
Replace
<new-url>
with the new URL you want to use.
Example:
Let's say the original remote URL is https://github.com/olduser/oldrepo.git
, and you want to change it to git@github.com:newuser/newrepo.git
.
Check the current remote URL
git remote -v
Update the origin
to the new SSH URL:
git remote set-url origin git@github.com:newuser/newrepo.git
Verify the update
git remote -v
After this, your Git repository will be connected to the new remote URL!