Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
git global url insteadOf setup
# one or the other, NOT both
[url "https://github"]
insteadOf = git://github
# or
[url "git@github.com:"]
insteadOf = git://github

Replace git:// with https://

Rewrite any git:// urls to be https:// but, it won't touch sshurls (git@github.com:)

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

or replace with ssh

Use ssh instead of https://

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

sauce: https://gist.github.com/grawity/4392747 & @hansdg1

@cristofor-dev
Copy link

cristofor-dev commented Nov 12, 2018

Thanks for the info

@AdiFahmi
Copy link

AdiFahmi commented Nov 20, 2019

Do you know how to set up with custom port? the default is 22

@fantasyczl
Copy link

fantasyczl commented Dec 2, 2019

Thanks

@Kastilo
Copy link

Kastilo commented Sep 30, 2021

Hello, I tried to do this, so I attempted to git clone with https to see if it would override to ssh, but it seems to keep failing, is there anyway to force this?

Picture Link of Issue

@timmyyuan
Copy link

timmyyuan commented Oct 20, 2021

Pardon me, how to unset insteadOf in git global settings?

@tribela
Copy link

tribela commented Jan 17, 2022

@timmyyuan Pardon me, how to unset insteadOf in git global settings?

git config --global -e bring the editor for your git config. remove related setting on there

@timmyyuan
Copy link

timmyyuan commented Jan 17, 2022

Thanks @tribela , I have found another way to remove this setting:

git config --global --remove-section url."https://github.com/"

@IzhakJakov
Copy link

IzhakJakov commented Jan 17, 2022

Is there a way to do something like that instead?

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

# or

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

Basically without using the http:// or https:// prefix.

@tommy70404
Copy link

tommy70404 commented Jul 21, 2022

Thanks!

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