从 Windows Cmd 行运行 git:关键文件在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6127063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:59:44  来源:igfitidea点击:

Running git from Windows Cmd line: Where are key files?

gitsshmsysgit

提问by Uri

So I've installed msysgit, and run git successfuly from the bash shell.

所以我已经安装了 msysgit,并从 bash shell 成功运行了 git。

From within the bash shell, I've created keys with ssh-keygen- everything works fine.
Key files are in my %userprofile%\.sshfolder (from the bash shell, it is: ~/.ssh).
I'm able to connect to my server (unfuddle in my case).

在 bash shell 中,我创建了密钥ssh-keygen- 一切正常。
密钥文件在我的%userprofile%\.ssh文件夹中(来自 bash shell,它是:)~/.ssh
我能够连接到我的服务器(在我的情况下解开)。

Next, I do want to be able to run git from the Windows Cmd shell.
Adding c:\msysgit\binand c:\msysgit\mingw\binto the search path.
Git is working locallyjust fine: branch, merge, add, commit, checkout, ... working well.

接下来,我确实希望能够从 Windows Cmd shell 运行 git。
添加c:\msysgit\binc:\msysgit\mingw\bin到搜索路径。
Git 在本地工作得很好:分支、合并、添加、提交、结帐……运行良好。

However, trying to work with the server fails, with: 'Permission denied (publickey).'
It looks like git, when executed from command line looks at a different location trying to allocated the key files, or another reason causing it to fail.

但是,尝试使用服务器失败,显示:' Permission denied (publickey).'
它看起来像 git,当从命令行执行时,它会查看尝试分配密钥文件的不同位置,或者导致它失败的其他原因。

回答by JaredPar

To get the mysysgit command line to find the .ssh keys you'll need to have %HOME%point to the directory containing the .ssh folder

要让 mysysgit 命令行找到 .ssh 密钥,您需要%HOME%指向包含 .ssh 文件夹的目录

Often you can just do

通常你可以做

set HOME=%USERPROFILE%

回答by VonC

From a Windows DOS file, you need to define a %HOME%environment variable.

从 Windows DOS 文件中,您需要定义一个%HOME%环境变量。

HOMEdoesn't exist in a DOS session by default.
You can set it to %userprofile%, since this is already your current setting.
You also can add it to your user environment variables, in order for any DOS session to get it.

HOME默认情况下不存在于 DOS 会话中。
您可以将其设置为%userprofile%,因为这已经是您当前的设置。
您还可以将它添加到您的用户环境变量中,以便任何 DOS 会话都能获得它。