Por mais estranho que pareça, você precisará traduzir HTTPs em HTTPS para que funcione;
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
Pergunta
Eu gostaria de forçar todos os clone/puxões para obter os dados do SSH, mas continue a usar o HTTPS para push.
Meu comando sempre usará https (git clone https://
) e eu não posso alterar isso (muitos scrits usando), mas gostaria de forçar o clone a usar o SSH e continuar usando o HTTPS para push.
O que eu fiz (nesta ordem):
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "ssh://server/"
Mas tanto buscam e push estão sendo traduzidos para SSH:
$ git remote -v
origin ssh://server/repo.git (fetch)
origin ssh://server/repo.git (push)
E eu gostaria de ver algo assim:
$ git clone https://server/repo.git
$ git remote -v
origin ssh://server/repo.git (fetch)
origin https://server/repo.git (push)
Solução
Por mais estranho que pareça, você precisará traduzir HTTPs em HTTPS para que funcione;
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
Outras dicas
Usar git remote set-url --push
. Da documentação:
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.