Pregunta

Me gustaría forzar todos los clonos/extracciones para obtener los datos de SSH, pero continúa usando HTTPS para Push.

Mi comando siempre usará https (git clone https://) Y no puedo cambiar esto (muchos scritps usando) pero me gustaría obligar al clon a usar SSH y continuar usando HTTPS para Push.

Lo que hice (en este orden):

[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "ssh://server/"

Pero tanto Fetch como Push se traducen a SSH:

$ git remote -v
origin  ssh://server/repo.git (fetch)
origin  ssh://server/repo.git (push)

Y me gustaría ver algo como esto:

$ git clone https://server/repo.git
$ git remote -v
origin  ssh://server/repo.git (fetch)
origin  https://server/repo.git (push)
¿Fue útil?

Solución

Por extraño que parezca, deberá traducir HTTPS a HTTPS para que funcione;

[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"

Otros consejos

Usar git remote set-url --push. De la documentación:

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.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top