适用于 Windows 的 SourceTree 无法正常工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15547331/
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-09 10:22:26  来源:igfitidea点击:

SourceTree for Windows not working

windowsgitatlassian-sourcetree

提问by Koray Tugay

When I type git pull from command line, I can get the code without any problems.

当我从命令行输入 git pull 时,我可以毫无问题地获取代码。

When I open SourceTree for Windows, and try a Pull, I get:

当我打开适用于 Windows 的 SourceTree 并尝试拉取时,我得到:

git -c diff.mnemonicprefix=false -c core.quotepath=false fetch origin
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.



Completed with errors, see above.

What might I be doing wrong?

我可能做错了什么?

采纳答案by bojer

It seems like using SourceTree on windows you have to use Putty Agent. OpenSSH keys do not work.

在 Windows 上使用 SourceTree 似乎必须使用 Putty Agent。OpenSSH 密钥不起作用。

If you have only OpenSSH key:

如果您只有 OpenSSH 密钥:

  1. click Create or import SSH keysin Tools menu
  2. in putty key generator select Import keyfrom Conversions menu
  3. select your private key and click on save private key
  1. 单击工具菜单中的创建或导入 SSH 密钥
  2. 在腻子密钥生成器中,从“转换”菜单中选择“导入密钥”
  3. 选择您的私钥并点击保存私钥

You now have PPK file containing your key.

您现在拥有包含您的密钥的 PPK 文件。

In Source Tree Launch SSH Agentfrom tools menu and browse to your PPK file.

在源树中,从工具菜单启动 SSH 代理并浏览到您的 PPK 文件。

All operations should now work fine.

所有操作现在应该可以正常工作。

回答by weseze

This works if you authenticate using a public/private key pair:

如果您使用公钥/私钥对进行身份验证,这将起作用:

  1. Open Sourcetree and go to "Tools > Create or Import SSH Keys" (this will open a PuTTY Key Generator window) and click on "Generate".

  2. Once generated go to drupal.org and navigate to "My account > Profile > SSH Keys" and click "Add a public key".

  3. Copy the generated public key from the "PuTTY Key Generator" window ("Public key for pasting into OpenSSH authorized_keys file:") to drupal.org and save it.

  4. In the "PuTTY Key Generator" window enter a "Key passphrase" and "Confirm passphrase" and click "Save private key". Make sure to save it somwhere where you can find it again.

  5. Close the "PuTTY Key Generator" window and in SourceTree go to "Tools > Launch SSH Agent (Pageant)". You should be able to select your private key file here. (the one you just saved)

  6. Add your repository with the link provided by drupal.org. ([email protected]:project/your_project.git)

  1. 打开 Sourcetree 并转到“工具 > 创建或导入 SSH 密钥”(这将打开 PuTTY 密钥生成器窗口)并单击“生成”。

  2. 生成后,转到 drupal.org 并导航到“我的帐户 > 配置文件 > SSH 密钥”,然后单击“添加公钥”。

  3. 将生成的公钥从“PuTTY 密钥生成器”窗口(“粘贴到 OpenSSH 授权密钥文件的公钥:”)复制到 drupal.org 并保存。

  4. 在“PuTTY Key Generator”窗口中输入“Key passphrase”和“Confirm passphrase”,然后点击“Save private key”。确保将其保存在可以再次找到的地方。

  5. 关闭“PuTTY Key Generator”窗口,然后在 SourceTree 中转到“Tools > Launch SSH Agent (Pageant)”。您应该可以在此处选择您的私钥文件。(你刚刚保存的那个)

  6. 使用 drupal.org 提供的链接添加您的存储库。([email protected]:project/your_project.git)

回答by jhoanegar

You don't need to use Putty in Windows but it is recommended, otherwise you'll have to re-add your ssh key every time you start SourceTree.
To do this go to 'Tools -> Add SSH Key...' and select the key that you provided in your cloud server (Git, BitBucket...). Now you'll be able to push/pull correctly provided you cloned your repository using the ssh url.
Keep in mind that this may apply to you only if you can successfully push/pull from the command line, if you don't then you have some other kind of problem.
If you accidentally cloned your repository using the https url then:

在 Windows 中不需要使用 Putty,但建议使用,否则每次启动 SourceTree 时都必须重新添加 ssh 密钥。
为此,请转到“工具 -> 添加 SSH 密钥...”并选择您在云服务器中提供的密钥(Git、BitBucket...)。现在,如果您使用 ssh url 克隆了您的存储库,您将能够正确推/拉。
请记住,只有当您可以从命令行成功推/拉时,这才可能适用于您,否则您会遇到其他类型的问题。
如果您不小心使用 https url 克隆了您的存储库,则:

git remote set-url <remote> <ssh-uri>

Like:

喜欢:

git remote set-url origin [email protected]...