Skip to content

Instantly share code, notes, and snippets.

@Thithip
Created November 8, 2019 08:33
Show Gist options
  • Save Thithip/bf942f377b982eb59f6010cb4b5cbd0b to your computer and use it in GitHub Desktop.
Save Thithip/bf942f377b982eb59f6010cb4b5cbd0b to your computer and use it in GitHub Desktop.
Git: Using SSH indentification instead of HTTPS by default

Sometimes with package manager you can have some troubles to download private Git dependencies (I had trouble with go get in Go with a private repository). If it's an authentication issue, you can force Git to use SSH indentification instead of HTTPS (or opposite) with the following lines:

Add to .gitconfig file:

[url "ssh://git@github.com"]
        insteadOf = https://github.com

Or with command line:

git config --global url."ssh://git@github.com".insteadOf "https://github.com"

Of course you can reverse this with the opposite:

[url "https://github.com"]
        insteadOf = ssh://git@github.com

Or with command line:

git config --global url."https://github.com".insteadOf "ssh://git@github.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment