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.
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.
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
git remote set-url origin git@github.com:username/repo.git
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.
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.
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.
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.