【问题标题】:Git connect using ssh on windows在 Windows 上使用 ssh 进行 Git 连接
【发布时间】:2012-06-14 13:14:25
【问题描述】:

我已经阅读了一些问题,但仍然没有找到解决这个问题的方法

我在 Windows 上有 git,我想使用 ssh 连接到 github。 按照本教程https://help.github.com/articles/generating-ssh-keys 我已经成功设置了我的密钥

如果我打开一个 git-bash 并尝试 ssh github 我可以连接,所以这可行

ssh -T git@github.com
Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

这意味着 git-bash 实际上看到了我的密钥。但是,如果我尝试进行推送

git push origin master

git 提示我输入用户名和密码
谢谢你的帮助

编辑:通过使用 git 协议而不是 http 协议解决,我的错
所以替换这个

https://github.com/_user_/_repository_.git  

这个

git@github.com:_user_/_repository_.git  

在远程链接中

【问题讨论】:

标签: windows git github


【解决方案1】:

无需删除/添加,只需执行以下操作:

git remote set-url origin git@github.com:username/repo.git

【讨论】:

    【解决方案2】:

    您可能克隆了一个使用 https 协议而不是 git 协议的遥控器。您需要为 origin 重新定义遥控器。

    # Change this as needed.
    github_username="$LOGNAME"
    
    # Replace your remote, then push.
    git remote rm origin
    git remote add origin "git@github.com:${github_username}/${PWD##*/}.git"
    git push --tags --set-upstream origin master
    

    【讨论】:

      猜你喜欢
      • 2019-05-16
      • 2019-03-24
      • 1970-01-01
      • 2011-01-30
      • 2020-10-12
      • 1970-01-01
      • 2016-09-25
      • 2017-11-06
      • 2016-04-10
      相关资源
      最近更新 更多