باستخدام SSH بدلاً من ذلك https فقط لجلب/استنساخ

StackOverflow https://stackoverflow.com/questions/19842282

  •  29-07-2022
  •  | 
  •  

سؤال

أرغب في إجبار جميع الاستنساخ/السحب للحصول على البيانات من SSH ، ولكن الاستمرار في استخدام HTTPs للدفع.

سيستخدم أمرتي دائمًا https (git clone https://) ولا يمكنني تغيير هذا (الكثير من scritps باستخدام) ولكن أود إجبار الاستنساخ على استخدام SSH ، والاستمرار في استخدام 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.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top