无法获取 git 扩展来将某些内容推送到 github SSH 问题

发布于 2024-09-30 21:39:33 字数 1033 浏览 1 评论 0原文

我正在尝试使用 git 扩展,到目前为止我真的很喜欢它,但我无法推送到 github。以下命令在 git bash 中工作正常:

git push "origin" master:master

然后当我使用 git 扩展推送时,我得到这个:

C:\Program Files\Git\bin\git.exe push "origin" master:master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Done

在 git 设置中,它只选择了 openSSH,我想保留它,因为 putty 似乎更麻烦。

我在 gitextensions 中添加的远程地址,实际上我在 bash 中所做的唯一测试就是上面的命令并生成 SSH 密钥。其他所有内容都在 git 扩展中设置。所以我想一切都必须正确设置。例如,电子邮件地址和姓名是正确的...

ssh [email protected]

也可以正常连接,来自 bash

编辑

因此我可以通过将 git-extensions 中的命令放入 cmd 来重现错误。显然,从 git bash 运行和从 cmd 运行之间存在差异,并且 git-extensions 像 Windows 命令一样运行此命令......有任何线索吗?

更新: 如果我从 git-extensions 的菜单中选择 git-bash,我会得到一个与我在资源管理器中右键单击我的存储库文件夹并在此处选择 git bash 时完全相同的窗口。现在,在从资源管理器打开的一个中,我可以推送,在从扩展打开的一个中,我遇到了公钥问题。

Im trying to use git extensions and I really like it so far, but I don't manage to push to github. The following command works fine in git bash:

git push "origin" master:master

and then when I push with git extensions I get this:

C:\Program Files\Git\bin\git.exe push "origin" master:master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Done

In the git settings it just has openSSH selected which I would like to keep because putty seems more hassle.

The remote addres I have added in gitextensions, actually the only thing I have done from the bash just to test is the command above and gerenating the SSH keys. All else is set up in git extensions. So I suppose everything must be set up correctly. Eg, the email adress and name are correct...

ssh [email protected]

also connects fine, from bash

edit:

So I can reproduce the error by putting the command from git-extensions in cmd. Appearantly there is a difference between running from git bash and from cmd and git-extensions runs this command like a windows command... any clues?

update:
If I choose git-bash from the menu in git-extensions I get a window that is exactly the same as when I right click in explorer on my repo folder and choose git bash here. Now, in the one opened from explorer I can push and in the one opened from extensions I get the public key problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

微凉 2024-10-07 21:39:33

要检查的事项:

  1. HOME 环境变量是否存在。
  2. 存在 %HOME%\.ssh\ 和 RSA 密钥。

当您从命令提示符运行 git 时,最好运行 git.cmd,因为它会自动修复 HOME

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

要修复 gitextensions,请定义 HOME 变量并将其设置为与 USERPROFILE 相同的值

Things to check for:

  1. Presence of HOME environment variable.
  2. Presence of %HOME%\.ssh\ and RSA keys there.

When you run git from command promt it is preferred to run git.cmd, because it fixes HOME automatically:

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

To fix gitextensions, define HOME variable and set it to same value as USERPROFILE

凌乱心跳 2024-10-07 21:39:33

好的,我解决了。

我从 git 扩展打开了 git bash,并使用资源管理器 shell 扩展打开了 git bash。然后,我从两者运行 ssh -vvv [email protected] 来查看差异。

事实证明,因为我更改了 git 配置文件的位置(我倾向于时不时地重新格式化,所以 c:\documents and settings... 对于存储我可能想要保留的任何内容来说是出了名的糟糕),当运行时从 git 扩展 git 还在不同的位置寻找 ssh 密钥。因此,我添加了 .ssh 文件夹,其中包含我的 git cofig 文件,现在它工作正常。我认为 git-extensions 将 git 的 HOME 变量设置为您设置为配置文件路径的任何内容。

现在,这并不明显......

Ok, I solved it.

I opened the git bash from git extensions and a git bash using the explorer shell extensions. I then ran ssh -vvv [email protected] from both to see the difference.

It turned out that because I changed the location of the git config file ( I tend to reformat every now and then, so c:\documents and settings... is notoriously bad for storing anything I might want to keep persistent), when run from git extensions git was also looking for the ssh keys in a different location. So I added the .ssh folder where my git cofig file is and now it works fine. I think git-extensions sets the HOME variable for git to whatever you set as path for the config file.

Now, that was not obvious...

走过海棠暮 2024-10-07 21:39:33

正确的答案是来自“max”的答案(手动设置你的 HOME 环境变量),但它可能有助于一些人理解问题发生的原因(随着 Git 在世界各地获得更多用户,这将变得非常常见)。

Cygwin 将 $HOME 设置为 /home/yourname,但该变量在 Windows 环境中未知。因此,如果您打开 bash 窗口并执行 env | grep HOME 你会看到这里提到的所有三个“HOME”变量,你可能想知道为什么 Gitextensions 不使用正确的 cygwin HOME - 这是因为它的 .bat 文件调用看不到它 - 它只看到你看到的内容在 Windows 控制台中进行“设置”。

令人费解的是,为什么它不稍后进行此评估并获取正确的 cygwin 路径,因为它知道如何调用 bash,但是(至少在 2.41 之前的版本中)您必须在设置或 .gitconfig 中进行手动更改。

The correct answer is the one from 'max' (set your HOME env var manually), but it may help some to understand why the problem is happening (as Git gets more users around the world it's going to be very common).

Cygwin sets $HOME to /home/yourname, but that variable is not known in the Windows environment. So if you open a bash window and do env | grep HOME you'll see all three 'HOME' variables mentioned here, and you might wonder why Gitextensions doesn't use your proper cygwin HOME - which is because its .bat file invocation doesn't see it - it only sees what you see from doing 'set' in a windows console.

It's mystifying why it doesn't do this evaluation later and get the proper cygwin path since it knows how to invoke bash, but (at least in versions up to 2.41) you have to do this manual change in the settings or in .gitconfig.

飞烟轻若梦 2024-10-07 21:39:33

当您直接启动 git bash 时,您将进入 MSYS 的主文件夹。您需要确保您的 ssh 密钥(id_rsa?)位于 .ssh 子文件夹(相对于主文件夹)中。

When you fire up git bash directly you'll land in your home folder for MSYS. You need to make sure you have your ssh key (id_rsa ?) in the .ssh subfolder (relative to the home folder).

热风软妹 2024-10-07 21:39:33

很高兴你解决了问题。因为这听起来像是一个严重的问题,所以我对从 GitExtensions 启动时 git-bash 之间的区别感兴趣。在 GitExtensions 中有一个设置可以解决这个问题。 %HOME% 目录可以在 GitExtensios 中更改。默认情况下,它将设置为 %HOMEDRIVE%%HOMEPATH%,但您可以覆盖它。更改此设置可能会解决您的问题,因为您认为这就是问题所在。要更改此设置,请打开设置对话框并转到选项卡“git”。在“环境”部分中,您可以设置%HOME%路径。

如果您让我知道这是否也解决了问题,我将不胜感激。我也对最初造成这种情况的原因感兴趣。也许我可以改进对有效主目录的检查。

Glad you solved the problem. Since this sounds like a serious problem I'm interested in the difference between git-bash when started from GitExtensions. In GitExtensions there is a setting that might fix this. The %HOME% directory can be changed in GitExtensios. By default it will be set to %HOMEDRIVE%%HOMEPATH%, but you can override this. Changing this probably solves your problem, since you suggest this is the problem. To change this open the settings dialog and go to the tab "git". In the section "Environment" you can set the %HOME% path.

I will appreciate it if you let me know if this also solves the problem. I'm also interested in what caused this in the first place. Maybe I can improve the check for a valid HOME directory.

你是年少的欢喜 2024-10-07 21:39:33

是的,不设置 HOME 变量对我来说也是问题。

将 HOME 变量设置为 %USERPROFILE% 并重新生成私钥和公钥,然后尝试克隆 - 现在应该可以工作了。

Yes, not setting the HOME varible was the issue for me too.

Set the HOME variable as %USERPROFILE% and regenerate the Private and Public keys, then try cloning—it should work now.

时光是把杀猪刀 2024-10-07 21:39:33

我看到 HOME 变量在 git 扩展中设置为 USERPROFILE。我可以添加和提交,但不能从远程存储库推送/拉取。我无法连接到任何远程存储库。我们使用 http(不是 ssh)进行连接。但是,使用 git bash 我可以连接到远程并进行推/拉。我已经提出了我的问题 GIT 扩展无法连接到远程,但 git bash 确实并且被定向到这个问题。但是,我无法解决我的问题。有什么想法吗?

I see that the HOME variable is set to USERPROFILE in git extensions. I can add and commit but not push/pull from the remote repository. I am unable to connect to any remote repository. We use http (not ssh) for the connection. However, using git bash I am able to connect to the remote and do push/pull. I had put my issue GIT extensions does not connect to remote but git bash does and was directed to this issue. However, I am unable to resolve my issue. Any ideas?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文