gpt4 book ai didi

github - 如何设置git使用ssh而不是https?

转载 作者:行者123 更新时间:2023-12-02 14:03:25 26 4
gpt4 key购买 nike

$ git remote -v

origin https://github.com/my-repo/site-web.git (fetch)

origin https://github.com/my-repo/site-web.git (push)


我已经设置了ssh并运行了一个shell脚本,如下所示:
ssh -T git@github.com
git reset --hard
...
git pull
但是我仍然被提示输入密码。我认为远程服务器必须是git@github.com才能使ssh正常工作。
我有四个目录... a/ b/ c/d/,它们都指向此远程目录。但是我真的只希望ssh在 a/中工作。我很高兴继续为其他人使用https。
我该怎么办?

最佳答案

如果a /是git仓库,则可以简单地更改其远程:

cd a
git remote set-url origin git@github.com/my-repo/site-web.git

但是,如果 abcd是同一存储库的文件夹,则将更改所有它们的来源。

要仅对 a/使用ssh,您将需要一个 separate clone, as a sparse checkout,以便仅使用 a/内容(并为该单独的克隆提供正确的远程URL)。

关于github - 如何设置git使用ssh而不是https?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27499004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com