As strange as it seems, you'll need to translate https to https for it to work;
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
Question
I would like do force all clone/pulls to get the data from SSH, but continue to use HTTPS for push.
My command will always use https (git clone https://
) and I can´t change this (lot of scritps using) but I would like to force the clone to use SSH, and continue to use HTTPS for push.
What I did (in this order):
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "ssh://server/"
But both fetch and push are being translated to SSH:
$ git remote -v
origin ssh://server/repo.git (fetch)
origin ssh://server/repo.git (push)
And I would like to see something like this:
$ git clone https://server/repo.git
$ git remote -v
origin ssh://server/repo.git (fetch)
origin https://server/repo.git (push)
Solution
As strange as it seems, you'll need to translate https to https for it to work;
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
OTHER TIPS
Use git remote set-url --push
. From the documentation:
set-url
Changes URL remote points to. Sets first URL remote points to
matching regex <oldurl> (first URL if no <oldurl> is given)
to <newurl>. If <oldurl> doesn’t match any URL, error occurs and
nothing is changed.
With --push, push URLs are manipulated instead of fetch URLs.
With --add, instead of changing some URL, new URL is added.
With --delete, instead of changing some URL, all URLs matching
regex <url> are deleted. Trying to delete all non-push URLs is an error.