[英]Unable to use git from Powershell 7.1 in Windows 10
I installed Git for Windows and Powershell 7.1.我为 Windows 和 Powershell 7.1 安装了 Git。 When I try to clone a repository from git bash using ssh key, it works perfectly.当我尝试使用 ssh 密钥从 git bash 克隆存储库时,它工作得很好。 However when I try to do similar from Powershell 7.1, I get a fatal: Could not read from remote repository error.但是,当我尝试从 Powershell 7.1 执行类似操作时,我得到一个致命的:无法从远程存储库读取错误。
Steps Followed遵循的步骤
1. PS> Start-Service ssh-agent
2. PS> ssh-add D:\Keys\.ssh\my_private_key (I get identity added message)
3. PS> git clone git@github.com:my-username/my-repo.git
Error Message错误信息
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
That means ssh, in that Powershell session, is trying to look for SSH keys at %USERPROFILE%
instead of D:\Keys
That means ssh, in that Powershell session, is trying to look for SSH keys at %USERPROFILE%
instead of D:\Keys
Check in your git bash if you have a ~/.ssh/config
file which would specify the right private key to use for Host github.com
. Check in your git bash if you have a ~/.ssh/config
file which would specify the right private key to use for Host github.com
.
And check what ~
(that is echo $HOME
) resolves in said git bash
session.并检查~
(即echo $HOME
)在git bash
session 中解决了什么问题。
If should not be the same as the default HOME in a Powershell session, where git defaults to %USERPROFILE%
如果不应该与 Powershell session 中的默认 HOME 相同,其中 git 默认为%USERPROFILE%
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.