奇妙なように、HTTPSをHTTPSに翻訳して、機能する必要があります。
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
質問
すべてのクローン/プルをSSHからデータを取得させるように強制したいと思いますが、引き続きHTTPSをプッシュに使用します。
私のコマンドは常にhttpsを使用します(git clone https://
)そして、私はこれを変更することはできません(多くのScritpsを使用して)が、クローンにSSHを使用するように強制し、PushにHTTPSを使用し続けたいと思います。
私がしたこと(この順序で):
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "ssh://server/"
しかし、フェッチとプッシュの両方がSSHに翻訳されています。
$ git remote -v
origin ssh://server/repo.git (fetch)
origin ssh://server/repo.git (push)
そして、私はこのようなものを見たいです:
$ git clone https://server/repo.git
$ git remote -v
origin ssh://server/repo.git (fetch)
origin https://server/repo.git (push)
解決
奇妙なように、HTTPSをHTTPSに翻訳して、機能する必要があります。
[url "ssh://server/"]
insteadOf = "https://server/"
[url "https://server/"]
pushInsteadOf = "https://server/"
他のヒント
使用する git remote set-url --push
. 。ドキュメントから:
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.