Git: force to use SSH URL instead of HTTPS for github.com

You can instruct git to use the SSH git clone url (git@...) instead of HTTPS one (https://) in every case.

Regardless of whether e.g. your CocoaPods spec includes the SSH or HTTPS github.com git clone url git will always use the SSH one (git@) this way. This can be useful if you use private submodules or CocoaPods spec/repos or any other tool which uses git and you want to force them to use SSH git clone URLs instead of HTTPS ones, as explained at: http://devcenter.bitrise.io/faq/adding-projects-with-submodules/

To reconfigure git to use SSH git clone URLs for github instead of HTTPS ones just run (e.g. using a Script step):

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

This instructs git that in every case when the git clone URL starts with https://github.com/ it should replace it with git@github.com: before contacting the server.

Note: this affects every git operation after running this git config, for github.com repos! It will always convert the URL and will use the SSH url instead for github.com repos.

Hello,

My private repo is hosted on bitbucket.org and I tried your suggestion but with bitbucket.org and it didn’t work :confused:

Any suggestions @viktorbenei ?

Hello there,

Can you please send us the log file or the URL of the related build and also enable Support Access on the Settings tab of the app ( Enabling the Bitrise Support user for your app | Bitrise DevCenter ) so that we can take a more in-depth look? :slight_smile: