Skip to content

Instantly share code, notes, and snippets.

@taoyuan
Last active November 18, 2024 08:50
Show Gist options
  • Save taoyuan/bfa3ff87e4b5611b5cbe to your computer and use it in GitHub Desktop.
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://
@magic990619
Copy link

It's working! Many Thanks

@younasm
Copy link

younasm commented May 22, 2021

Please someone help me I tried so many things but it's not working. I'm trying to npm install to install the dependencies for the Github repository it installs some dependencies but at the end, it shows this ERROR.

npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://github.com/debris/bignumber.js.git
npm ERR!
npm ERR! Host key verification failed.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Younas\AppData\Roaming\npm-cache_logs\2021-05-22T06_40_23_639Z-debug.log

@BodhiHu
Copy link

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

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

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

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

@joseboretto
Bro, you saved me headache. Thanks.

@sd445419855
Copy link

Thank you!! You just saved my life.

@E-wallace0001
Copy link

All the yes. Thank you !

@tamipangadil
Copy link

This worked like a charm 🥇

@iamnothere101
Copy link

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