git 如何安装/设置 TortoiseGit 以使用 GitHub

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

How to install/setup TortoiseGit to work with GitHub

gitgithubcygwintortoisegit

提问by Mr. Boy

I have just installed Git For Windows, and created my SSH key using SSH through Cygwin. It seems to be working from command-line and the Git For Windows GUI, but now I want to use TortoiseGit. TortoiseGit uses a Putty-like SSH client by default but apparently GitHub only accepts (open)SSH, and I don't really know how to proceed. I will be doing a clean TortoiseGit install, I already have Cygwin and Git for Windows installed.

我刚刚安装了Git For Windows,并通过 Cygwin 使用 SSH 创建了我的 SSH 密钥。它似乎在命令行和 Git For Windows GUI 中工作,但现在我想使用 TortoiseGit。TortoiseGit 默认使用类似 Putty 的 SSH 客户端,但显然 GitHub 只接受(开放)SSH,我真的不知道如何进行。我将进行干净的 TortoiseGit 安装,我已经安装了用于 Windows 的 Cygwin 和 Git。

回答by zcrar70

For anyone looking to change an existing TortoiseGit installation to use PuTTYrather than OpenSSH, simply right-click, -> TortoiseGit-> Settings-> Network, then change 'ssh.exe' to 'tortoiseplink.exe'. From then on, doing a push/pull should be using Pageant (and any keys you have set up in there) if you also have that running.

对于希望更改现有 TortoiseGit 安装以使用PuTTY而不是OpenSSH 的任何人,只需右键单击 -> TortoiseGit-> Settings-> Network,然后将“ssh.exe”更改为“tortoiseplink.exe”。从那时起,执行推/拉应该使用 Pageant(以及您在其中设置的任何键),如果您也运行它。

回答by Learath2

The easiest way would be first installing TortoiseGit then msysgit with the setting SSH client to TortoisePLink. Use the TortoiseGit Puttykey generator to create a new keypair add your public key to GitHub.

最简单的方法是先安装 TortoiseGit,然后安装 msysgit,将 SSH 客户端设置为 TortoisePLink。使用 TortoiseGit Puttykey 生成器创建一个新的密钥对,将您的公钥添加到 GitHub。

Clone/create a new repository. In thee Tortoise repository settings, set your fullname and email. Then in remote menu under the Git configuration menu enter your clone URL and select your PuTTY key. GitHub works just fine with PuTTY keys. I have friends that use it, and I used it myself too.

克隆/创建一个新的存储库。在 Tortoise 存储库设置中,设置您的全名和电子邮件。然后在 Git 配置菜单下的远程菜单中输入您的克隆 URL 并选择您的 PuTTY 密钥。GitHub 与 PuTTY 密钥一起工作得很好。我有朋友在用它,我自己也用过。

回答by ydrozhdzhal

1) Cygwin

1) 赛格温

Use the approach described in the article Working with SSH key passphrases.

使用文章使用 SSH 密钥密码中描述的方法。

A password will be asked for only once on the Cygwin session startup. !!! Before exiting the Cygwin session don't forget to kill the ssh-agent process (use ps for find process PID and kill -9).

Cygwin 会话启动时只会要求输入一次密码。!!!在退出 Cygwin 会话之前,不要忘记终止 ssh-agent 进程(使用 ps 查找进程 PID 并使用 kill -9)。

We are using a separate approach for Cygwin, because Cygwin by some reason doesn't see processes started externally in a Windows environment.

我们对 Cygwin 使用了一种单独的方法,因为由于某种原因,Cygwin 看不到在 Windows 环境中从外部启动的进程。

2, 3) MsysGit, TortoiseGit

2, 3) MsysGit, TortoiseGit

Useful link: http://dogbiscuit.org/mdub/weblog/Tech/WindowsSshAgent

有用的链接:http: //dogbiscuit.org/mdub/weblog/Tech/WindowsSshAgent

Install MsysGit. Install TortoiseGit (check openssh instead of plink during installation). !!! Check systems variables. If there is GIT_SSH variable present - remove it.

安装 MsysGit。安装 TortoiseGit(在安装过程中检查 openssh 而不是 plink)。!!!检查系统变量。如果存在 GIT_SSH 变量 - 将其删除。

Go to TortoiseGit-> Settings-> General.

转到TortoiseGit->设置->常规

Set the Git EXE path to <MsysGitHome>/bin. Set the external DLL path to <MsysGitHome>/mingw/bin.

将 Git EXE 路径设置为 <MsysGitHome>/bin。将外部 DLL 路径设置为 <MsysGitHome>/mingw/bin。

Go to TortoiseGit-> Settings-> Network. Set the SSH Client property to <MsysGitHome>/bin/ssh.exe

转到TortoiseGit->设置->网络。将 SSH 客户端属性设置为 <MsysGitHome>/bin/ssh.exe

Define system variable SSH_AUTH_SOCKS=C:\temp.ssh-socket

定义系统变量 SSH_AUTH_SOCKS=C:\temp.ssh-socket

Start cmd.exe and execute following commands (since we installed MsysGit all following commands are accessible in cmd - <MsysGit>/bin is added to system PATH variable):

启动 cmd.exe 并执行以下命令(因为我们安装了 MsysGit,所以以下所有命令都可以在 cmd 中访问 - <MsysGit>/bin 添加到系统 PATH 变量中):

# The following command is required to execute for avoiding an address already bind message when ssh-agen is not started yet but .ssh-socket exists after previous agent session
rm "%SSH_AUTH_SOCK%"

# Starting ssh-agent
ssh-agent -a "%SSH_AUTH_SOCK%"

# Adding our openssh key
ssh-add "%USERPROFILE%\.ssh\id_rsa"

# Type password for your key

That's it. From that moment you can execute git push, git pullfrom TortoiseGit and MsysGit without a prompting passphrase.

就是这样。从那一刻起,您可以从 TortoiseGit 和 MsysGit执行git pushgit pull而无需提示密码。

When ssh-agent is no longer required you can kill it through Windows Task Manager.

当不再需要 ssh-agent 时,您可以通过 Windows任务管理器终止它。