Change the Remote Git URL with Set Remote Origin |Video upload date:  · Duration: PT1M0S  · Language: EN

Quick guide to change a Git remote URL using git remote set-url origin and verify the change with git remote -v

So you need to change a Git remote url and you want to do it without turning your repo into an existential crisis. Relax. This short guide covers the exact git commands you need to switch the origin remote url and verify that your pushes and fetches still behave like civilized software.

Inspect the current remote

Before you start poking things run this to see what origin is currently pointing at

git remote -v

This lists your remotes and their urls for fetch and push. If origin points to the wrong host or protocol you will know before you make a mess. Knowledge saves time and credibility.

Set the new origin remote url

Use the git remote set-url command to update origin. Replace new_repo_url with the SSH or HTTPS address you want

git remote set-url origin new_repo_url

Examples that actually look like something

SSH example

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

HTTPS example

git remote set-url origin https://github.com/username/repo.git

If you switch from HTTPS to SSH or vice versa be sure your authentication matches. If SSH keys are set up you will avoid repeated password prompts and general grumbling.

Verify the change

Do the same check again to confirm you did not mistype anything

git remote -v

If the url looks wrong double check for typos and confirm you used the correct protocol. A single character can make Git very dramatic.

Test connectivity and permissions

Before you push real work try a fetch or a dry run push to prove the remote does not hate you

git fetch
# or
git push --dry-run origin your-branch-name

Successful fetch or dry run means your git commands, credentials, and remote are all on speaking terms. If authentication fails update credentials or add your SSH key to the remote host.

Troubleshooting tips and quick wins

  • If Git keeps asking for passwords consider enabling a credential helper or switch to SSH keys for fewer prompts and less annoyance
  • If you have submodules remember they can point to their own remotes and may need updating too
  • Check for accidental extra slashes or stray .git fragments when copying urls
  • When moving between providers make sure you have permission to push to the target repository or the push will be politely rejected

Recap

Inspect your remotes with git remote -v. Update origin with git remote set-url origin new_repo_url. Verify with git remote -v. Test with git fetch or a dry run push. If you switch protocols update authentication accordingly. Follow these steps and your version control life will be only mildly inconvenient rather than catastrophic.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.