• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Dev Tips / Git Change Remote to https

Git Change Remote to https

Last updated on July 28, 2026 by Sal Ferrarello

I had to change a bunch of Git remotes from GitHub SSH URLs (e.g. git@github.com:salcode/salcode-zsh.git) to GitHub https URLs (e.g. https://github.com/salcode/salcode-zsh.git) on a bunch of different repos. This is how I made it easier for myself on my Mac.

Note: The following is Mac specific – this is not a cross-platform solution.

Quick and Dirty

You can run

git remote -v

to see your remotes. e.g.

$ git remote -v
origin  git@github.com:salcode/salcode-zsh.git (fetch)
origin  git@github.com:salcode/salcode-zsh.git (push)

And then run the following to update them to https.

for REMOTE in $(git remote); do
  echo $REMOTE
  before_url=$(git remote get-url $REMOTE)
  echo "BEFORE: ${before_url}"
  if [[ ! $before_url =~ ^git@github.com: ]]; then
    echo "Skipping remote $remote because it is not a valid GitHub SSH URL"
    echo "---------\n"
    continue
  fi
  git remote set-url $REMOTE https://github.com/$(git remote get-url $REMOTE | sed 's/https:\/\/github.com\///' | sed 's/git@github.com://')
  echo "AFTER: $(git remote get-url $REMOTE)"
  echo "---------\n"
done

This is based on this StackOverflow post How to change a connection to GitHub from SSH to HTTPS?

Leveraging GitHub CLI

Because I expect I’ll need to do this again some day (or perhaps do the reverse and convert from https to SSH), I’ve put together a quick GitHub CLI extension (see salcode/gh-remote-convert).

If you have gh (the GitHub CLI) installed, you can run

gh extension install salcode/gh-remote-convert && gh remote-convert https --all

If you decide to go this route, you can optionally remove the extension from your install when you’re done by running

gh extension remove remote-convert
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Dev Tips, Solution Tagged With: command line, Git, GitHub

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in