Force git to use ssh instead of HTTPS

Sometimes you have tools that reference a github url with https and you want them to use ssh instead so your ssh key works.

In my case it is Cocoapods trying to clone a spec repo. Since I just enabled two-factor auth on my account it now stopped working:

Matts-iMac:Nutrition matt$ pod install
Cloning spec repo `enquos` from ``
Username for '': hammertoe
Password for '': 
[!] Unable to add a source with url `` named `enquos`.
You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.

By putting the following in your ~/.gitconfig file you can force git to use SSH whenever it is asked to use a HTTPS url:

[url ""]
  insteadOf =
[url ""]
  pushInsteadOf = "git://"
[url ""]
  pushInsteadOf = ""
Go Top
comments powered by Disqus