在没有 bash 的情况下在 Windows 7 上将 git 连接到 github [英] Connecting git to github on windows 7 without bash

查看:33
本文介绍了在没有 bash 的情况下在 Windows 7 上将 git 连接到 github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的新 Windows 7 机器上设置 git,但在让 github 确认我的 ssh 密钥方面遇到了障碍.我做的事情与标准脚本有点不同,因为我宁愿不使用 cygwin,而是更喜欢使用我的 powershell 提示符.以下是我所做的:

I'm setting up git on my new Windows 7 machine and I'm hitting a roadblock when it comes to getting github to acknowledge my ssh key. I am doing things a little different from the standard script in that I would rather not use cygwin and prefer to use my powershell prompt. The following is what I did:

  1. 我安装了 msysgit(便携式).
  2. 我去了 C:program filesgitin 并使用 ssh-keygen 生成了一个公共/私有 ssh 密钥对,我把它放在 c:Temp 中
  3. 然后我在 c:Usersmyusername 中创建了一个名为 .ssh 的目录(在 Windows 7 上)
  4. 我将 ssh-keygen 生成的两个文件(id_rsa 和 id_rsa.pub)都移到了 .ssh 目录中
  5. 我去了我在 github 上的帐户,创建了一个新的公钥,将 id_rsa.pub 的内容复制粘贴到其中并保存
  6. 我现在转到我的 powershell 提示符,set-alias git 'C:program filesgitingit.exe'
  7. 我现在尝试克隆 git@github.com:togakangaroo/ps-profile.git 拒绝我的身份验证:

  1. I installed msysgit (portable).
  2. I went to C:program filesgitin and used ssh-keygen to generate a public/private ssh keypair which I put in c:Temp
  3. I then created a directory named .ssh in c:Usersmyusername (on windows 7)
  4. I moved both the files generated by the ssh-keygen (id_rsa and id_rsa.pub) into the .ssh directory
  5. I went to my account on github, created a new public key, copy-pasted the contents of id_rsa.pub into it and saved
  6. I now go to my powershell prompt, set-alias git 'C:program filesgitingit.exe'
  7. I try to now do a clone git@github.com:togakangaroo/ps-profile.git which rejects my authentication:

权限被拒绝(公钥).致命:远端意外挂断

Permission denied (publickey). fatal: The remote end hung up unexpectedly

过去的经验表明这意味着 git 无法识别我的密钥.我错过了哪些步骤?

Past experience says that this means git is not recognizing my key. What steps am I missing?

我有一种感觉,我需要以某种方式配置 git,以便它知道我的 ssh 密钥在哪里(尽管它似乎应该自动出现在那里)但我不知道该怎么做.

I have a feeling that I need to somehow configure git so that it knows where my ssh keys are (though it would seem it should look there automatically) but I don't know how to do that.

另一个可能的线索是,当我尝试运行 git config --global user.name "George Mauer"我收到一个错误

Another possible clue is that when I try to run git config --global user.name "George Mauer" I get an error

fatal: $HOME not set

我确实设置了一个值为 %HOMEDRIVE%%HOMEPATH% 的 HOME 环境用户变量

I did however set up a HOME environment user variable with the value %HOMEDRIVE%%HOMEPATH%

推荐答案

您要查找的命令是:ssh-add C:path okey

首先,您可能想通过运行 ssh -v git@github.com

First, you may want to find out where ssh is currently looking for your keys, by running ssh -v git@github.com

这篇关于在没有 bash 的情况下在 Windows 7 上将 git 连接到 github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆