Git – Change Remote URL
source link: https://www.shellhacks.com/git-change-remote-url/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Git – Change Remote URL
When managing a Git repository, there are several scenarios where updating the remote URL becomes necessary:
- Repository Migration: When moving the repository to a different location or hosting service, the remote URL needs updating.
- Switching Protocols: Developers may switch from HTTPS to SSH for security or convenience.
- Ownership Changes: If the username or ownership of the repository changes, the URL must be updated.
To update the remote URL in Git, you can use the git remote set-url
command.
Cool Tip: How to migrate your Git repository to GitHub, GitLab, Bitbucket or any other Git server! Read more →
Change Git Remote URL
Use the following command to change the Git remote URL:
$ git remote set-url origin <NEW_URL>
Replace <NEW_URL>
with the new URL of your remote repository.
For example, if you’re setting an HTTPS URL, it would look something like this:
$ git remote set-url origin https://github.com/shellhacks/WordPress.git
And for SSH, it would be:
$ git remote set-url origin ssh://github.com:shellhacks/WordPress.git
Cool Tip: How to show remote URLs in Git & check origin
! Read more →
After updating the remote URL, you can verify that the change was successful by listing the remote connections with:
$ git remote -v
This will show you the updated URLs for both fetch
and push
operations.
Remember, changing the remote URL won’t affect your repository’s history or data as long as the new URL points to the same repository or a fork of it.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK