3

I want to clone some github repositories to computers that have only access to github via an SSH tunnel.

I can use the ssh addresses to clone simple repositories without problems.

When a repository contains submodules, the access method is controled by .gitsubmodules which often default to https addresses (since this is the recommended way by github).

Is there a way to tell git submodules that it should always use ssh access, even when the address of a submodule is an https address?

Having to clone a repo and modify its .gitsubmodules just to be able to clone it through an ssh tunnel seems retarded. Hardcoding the access method in a .gitsubmodules file instead of letting your users choose the appropiate method seems pretty retarded too. I guess there must be a better way but I cannot find it.

2 Answers 2

2

You may use git to rewrite the urls

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

You may include a hostname in the expression to restrict the rewrite to a specific host

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

If you do not whant the rewrite rules to be global then just add it to your local scope instead.

See more under section url.<base>.insteadOf at http://git-scm.com/docs/git-config

Sign up to request clarification or add additional context in comments.

4 Comments

I like this answer more but I don't know about setting it globally in the event that certain repos are only available via HTTPS (unless your specifically unable to as the OP is)
maybe url."[email protected]:".insteadOf github.com will work for github, gonna try (UPDATE: It works, thanks!)
@osxi, you may just add the rewrite rules to the local scope instead.
@gnzlbg, thanx for the feedback, I clarified the the answer
1

Changing the values in .gitmodules is a common way to change the protocol for submodules followed by a git submodule sync to update the remote repository locations.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.