【问题标题】:Moving from https to ssh on GITHUB在 GITHUB 上从 https 迁移到 ssh
【发布时间】:2021-11-10 00:23:27
【问题描述】:

我查找了其他问题,但没有得到与答案提供的相同结果。

我最初使用 https 使用 github 存储库备份了我的 DigitalOcean droplet。

我已按照https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/about-ssh 的所有说明(多次)进行操作

我已删除旧的 .git 文件夹。 我根据以下内容更新了 ~/.ssh/config 文件: How to permanently add a private key with ssh-add on Ubuntu?

每次我推送或“git push --set-upstream origin main”时,我都可以选择输入我的用户名和密码,然后因为使用 https 而被拒绝。

我还将我的 ~/.ssh/config 文件更新为:

    HostName github.com
    User git
    IdentityFile ~/.ssh/yourPrivateKeyName
    IdentitiesOnly yes

【问题讨论】:

  • 您是否将远程 URL 更改为使用 SSH 而不是 HTTPS?听起来不像你做的
  • Git 存储库不是进行备份的好方法,GitHub 不会感谢您使用他们的备份服务。您最好使用旨在以有效方式进行备份的真正备份解决方案(例如 bup 或 Tarsnap)。

标签: git github ssh


【解决方案1】:

要从 https 迁移到 ssh,您只需要一个

# replace <your-name> and <your-repo> with the real values.
git remote set-url origin git@github.com:<your-name>/<your-repo>.git

但是,为方便起见,您可以克隆一个新的本地存储库。

只需输入

# replace <your-name> and <your-repo> with the real values.
git clone git@github.com:<your-name>/<your-repo>.git my-new-local-repo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 2012-11-19
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 1970-01-01
    相关资源
    最近更新 更多