Skip to content

Instantly share code, notes, and snippets.

@taoyuan
Last active March 6, 2026 14:27
Show Gist options
  • Select an option

  • Save taoyuan/bfa3ff87e4b5611b5cbe to your computer and use it in GitHub Desktop.

Select an option

Save taoyuan/bfa3ff87e4b5611b5cbe to your computer and use it in GitHub Desktop.
Force git to use https:// instead of git://
# npm using https for git
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
# npm using git for https
git config --global url."[email protected]:".insteadOf https://github.com/
git config --global url."git://".insteadOf https://
@BodhiHu
Copy link
Copy Markdown

BodhiHu commented Jul 30, 2021

the inverse, forcing git to use ssh instead of https:

git config --global url."[email protected]:".insteadOf "https://github.com/"

@younasm
Copy link
Copy Markdown

younasm commented Aug 4, 2021

the inverse, forcing git to use ssh instead of https:

git config --global url."[email protected]:".insteadOf "https://github.com/"

did not work for me.

@adam-nielsen
Copy link
Copy Markdown

I needed to add another one to get it working with Node's NPM

git config --global url."https://github.com/".insteadOf ssh://[email protected]

This adds an ssh:// prefix and removes the : suffix. It allows downloading public packages from GitHub repositories in environments like Docker where there are no SSH keys.

@Connor-Flewitt
Copy link
Copy Markdown

If anyone found themselves unable to revert the config using the suggested commands, go into the git config editor and manually delete what you want to remove :)

git config --global -e

For anyone unfamiliar with the editor, press "i" to start editing, "esc" to stop editing, and " : -> w -> q " to save and quit the editor.

@robiparvez
Copy link
Copy Markdown

@joseboretto
Bro, you saved me headache. Thanks.

@sd445419855
Copy link
Copy Markdown

Thank you!! You just saved my life.

@E-wallace0001
Copy link
Copy Markdown

All the yes. Thank you !

@tamipangadil
Copy link
Copy Markdown

This worked like a charm 🥇

@vikramty
Copy link
Copy Markdown

When using ssh (git config --global url."[email protected]:".insteadOf https://github.com), is there a way to authenticate (using A PAT)? I know it's possible with https, don't see a way to provide a PAT (via Github secret) when using SSH method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment