Domanda

Vorrei forzare tutti i cloni/tiri per ottenere i dati da SSH, ma continuare a utilizzare HTTPS per la spinta.

Il mio comando utilizzerà sempre HTTPS (git clone https://) E non posso cambiare questo (molti scritti usando) ma vorrei forzare il clone a usare SSH e continuare a usare HTTPS per Push.

Quello che ho fatto (in questo ordine):

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

Ma sia Fetch che Push vengono tradotti in SSH:

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

E vorrei vedere qualcosa di simile:

$ git clone https://server/repo.git
$ git remote -v
origin  ssh://server/repo.git (fetch)
origin  https://server/repo.git (push)
È stato utile?

Soluzione

Per quanto strano sembri, dovrai tradurre HTTPS in HTTPS affinché funzioni;

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

Altri suggerimenti

Uso git remote set-url --push. Dalla documentazione:

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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top