git TortoiseGit 保存用户身份验证/凭据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14000173/
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
TortoiseGit save user authentication / credentials
提问by Murali Murugesan
Is there a way to save GITHUB's user credentials
with TortoiseGit?
有没有办法GITHUB's user credentials
用 TortoiseGit保存?
It prompts me the below dialog every time whenever I do a push/pull.
每当我执行推/拉操作时,它都会提示我以下对话框。
I would like to save my user credential information somewhere like how I did with TortoiseSVN.
我想将我的用户凭据信息保存在某个地方,就像我使用 TortoiseSVN 所做的那样。
回答by linquize
For TortoiseGit 1.8.1.2 or later, there is a GUI to switch on/off credential helper.
对于 TortoiseGit 1.8.1.2 或更高版本,有一个用于打开/关闭凭证助手的 GUI。
It supports git-credential-wincred
and git-credential-winstore
.
它支持git-credential-wincred
和git-credential-winstore
。
TortoiseGit 1.8.16 add support for git-credential-manager
(Git Credential Manager, the successor of git-credential-winstore
)
TortoiseGit 1.8.16 添加对git-credential-manager
(Git Credential Manager,的继承者git-credential-winstore
)的支持
For the first time you sync you are asked for user and password, you enter them and they will be saved to Windows credential store. It won't ask for user or password the next time you sync.
第一次同步时,系统会要求您输入用户名和密码,您输入它们并将它们保存到 Windows 凭据存储中。下次同步时它不会要求用户或密码。
To use: Right click → TortoiseGit → Settings → Git → Credential. Select Credential helper: wincred - this repository only / wincred - current Windows user
使用方法:右键单击 → TortoiseGit → 设置 → Git → 凭证。选择凭据助手:wincred - 仅此存储库 / wincred - 当前 Windows 用户
回答by Robert Rouhani
If you're going to downvote this answer
如果你要反对这个答案
I wrote this a few months prior to the inclusion of git-credential in TortoiseGit. Given the number of large security holes found in the last few years and how much I've learned about network security, I would HIGHLY recommend you use a unique (minimum 2048-bit RSA) SSH key for every server you connect to.
我在 TortoiseGit 中包含 git-credential 之前几个月写了这篇文章。鉴于过去几年发现的大量安全漏洞以及我对网络安全的了解程度,我强烈建议您为连接到的每台服务器使用唯一的(最低 2048 位 RSA)SSH 密钥。
The below syntax is still available, though there are far better tools available today like git-credential
that the accepted answer tells you how to use. Do that instead.
下面的语法仍然可用,尽管今天有更好的工具可用,就像git-credential
接受的答案告诉你如何使用一样。改为这样做。
Try changing the remote URL to https://[email protected]/username/repo.git
where username
is your github username and repo
is the name of your repository.
试着改变远程URL到https://[email protected]/username/repo.git
哪里username
是你的GitHub用户名和repo
为您的存储库的名称。
If you also want to store your password (not recommended), the URL would look like this: https://username:[email protected]/username/repo.git
.
如果您还想存储密码(不推荐),则 URL 将如下所示:https://username:[email protected]/username/repo.git
。
There's also another way to store the password from this github help article: https://help.github.com/articles/set-up-git#password-caching
还有另一种方法来存储此 github 帮助文章中的密码:https: //help.github.com/articles/set-up-git#password-caching
回答by Patrick Atoon
None of the above answers worked for me using git version 1.8.3.msysgit.0 and TortoiseGit 1.8.4.0.
使用 git 版本 1.8.3.msysgit.0 和 TortoiseGit 1.8.4.0,上述答案都不适用于我。
In my particular situation, I have to connect to the remote git repo over HTTPS, using a full blown e-mail address as username.
In this situation, wincred
did not appear to work.
在我的特定情况下,我必须使用完整的电子邮件地址作为用户名,通过 HTTPS 连接到远程 git 存储库。在这种情况下,wincred
似乎没有工作。
Using the email address as a part of the repo URL also did not work, as the software seems to be confused by the double appearance of the '@' character in the URL.
使用电子邮件地址作为 repo URL 的一部分也不起作用,因为该软件似乎对 URL 中“@”字符的双重出现感到困惑。
I did manage to overcome the problem using winstore
. Here is what I did:
我确实设法使用winstore
. 这是我所做的:
- Download
winstore
from http://gitcredentialstore.codeplex.com/ - Run
git-credential-winstore.exe
to install it.
winstore
从http://gitcredentialstore.codeplex.com/下载- 运行
git-credential-winstore.exe
安装它。
This will copy the git-credential-winstore.exe
to a local directory and add two lines to your global .gitconfig
. You can verify this by examining your global .gitconfig
. This is easiest done via right mouse button on a folder, "TortoiseGit > Settings > Git > Edit global .gitconfig". The file should contain two lines like:
这会将 复制git-credential-winstore.exe
到本地目录并将两行添加到您的全局.gitconfig
. 您可以通过检查您的全局.gitconfig
. 最简单的方法是通过鼠标右键单击文件夹“TortoiseGit > Settings > Git > Edit global .gitconfig”。该文件应包含两行,例如:
[credential]
helper = !'C:\Users\yourlogin\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
- No other TortoiseGit settings are needed under "Network" or "Credential". In particular: the "Credential helper" pull down menu under "Credential" will have gone blank as a result of these configuration lines, since TortoiseGit does not recognize the new helper. Do not set the pull down menu to another value or the global .gitconfig will be overwritten with an incorrect value! (*)
- 在“网络”或“凭据”下不需要其他 TortoiseGit 设置。特别是:由于这些配置行,“Credential”下的“Credential helper”下拉菜单将变为空白,因为 TortoiseGit 无法识别新的帮助器。不要将下拉菜单设置为其他值,否则全局 .gitconfig 将被错误的值覆盖!(*)
You are now ready to go:
您现在可以开始了:
- Try to pull from the remote repository. You will notice an authentication popup asking your username and password, the popup should be visually different from the default TortoiseGit popup. This is a good sign and means
winstore
works. Enter the correct authentication and the pull should succeed. - Try the same pull again, and your username and password should no longer be asked.
- 尝试从远程存储库中拉取。您会注意到一个询问您的用户名和密码的身份验证弹出窗口,该弹出窗口在视觉上应该与默认的 TortoiseGit 弹出窗口不同。这是一个好兆头,意味着
winstore
有效。输入正确的身份验证,拉取应该会成功。 - 再次尝试相同的拉取,您的用户名和密码将不再被询问。
Done!
Enjoy your interactions with the remote repo while winstore
takes care of the authentication.
完毕!winstore
在处理身份验证的同时享受与远程存储库的交互。
(*) Alternatively, if you don't like the blank selection in the TortoiseGit Credential settings helper pull down menu, you can use the "Advanced" option:
(*) 或者,如果您不喜欢 TortoiseGit Credential 设置助手下拉菜单中的空白选择,您可以使用“高级”选项:
- Go to "TortoiseGit > Settings > Credential"
- Select Credential helper "Advanced"
- Click on the "G" (for global) under Helpers
Enter the Helper path as below. Note:a regular Windows path notation (e.g. "C:\Users...") will not work here, you have to replicate the exact line that installing
winstore
created in the global.gitconf
without the "helper =" bit.!'C:\Users\yourlogin\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
Click the "Add New/Save" button
- 转到“TortoiseGit > 设置 > 凭据”
- 选择凭据助手“高级”
- 单击 Helpers 下的“G”(全局)
输入助手路径如下。注意:常规的 Windows 路径符号(例如“C:\Users...”)在此处不起作用,您必须复制安装
winstore
在全局中创建的确切行.gitconf
而没有“helper =”位。!'C:\Users\yourlogin\AppData\Roaming\GitCredStore\git-credential-winstore.exe'
单击“添加新/保存”按钮
回答by thinhnv
[open git settings (TortoiseGit → Settings → Git)][1]
[打开git设置(TortoiseGit→设置→Git)][1]
[In GIt: click to edit global .gitconfig][2]
[在GIt中:点击编辑全局.gitconfig][2]
回答by linquize
For msysgit 1.8.0, download git-credential-wincred.exe from https://github.com/downloads/msysgit/git/git-credential-wincred.zipand put into C:\Program Files\Git\libexec\git-core
对于 msysgit 1.8.0,从https://github.com/downloads/msysgit/git/git-credential-wincred.zip下载 git-credential-wincred.exe并放入 C:\Program Files\Git\libexec\git -核
For msysgit 1.8.1 and later, the exe is built-in.
对于 msysgit 1.8.1 及更高版本,exe 是内置的。
in git config, add the following settings.
在 git config 中,添加以下设置。
[credential] helper = wincred
[凭证] 助手 = wincred
回答by Anthony Keane
Saving username and password with TortoiseGit
使用 TortoiseGit 保存用户名和密码
Saving your login details in TortoiseGit is pretty easy. Saves having to type in your username and password every time you do a pull or push.
在 TortoiseGit 中保存您的登录详细信息非常简单。每次执行拉取或推送时都不必输入用户名和密码。
Create a file called _netrc with the following contents:
machine github.com
login yourlogin
password yourpasswordCopy the file to C:\Users\ (or another location; this just happens to be where I've put it)
Go to command prompt, type setx home C:\Users\
创建一个名为 _netrc 的文件,内容如下:
机器 github.com
登录 yourlogin
密码yourpassword将文件复制到 C:\Users\(或其他位置;这恰好是我放置它的位置)
转到命令提示符,键入 setx home C:\Users\
Note: if you're using something earlier than Windows 7, the setx command may not work for you. Use set instead and add the home environment variable to Windows using via the Advanced Settings under My Computer.
注意:如果您使用的是早于 Windows 7 的版本,则 setx 命令可能不适合您。改用 set 并通过“我的电脑”下的“高级设置”将家庭环境变量添加到 Windows。
CREDIT TO: http://www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/
信用:http: //www.munsplace.com/blog/2012/07/27/saving-username-and-password-with-tortoisegit/
回答by Denis Wang
If you are a windows 10 + TortoiseGit 2.7 user:
如果您是 Windows 10 + TortoiseGit 2.7 用户:
- for the first time login, simply follow the prompts to enter your credentials and save password.
- If you ever need to update your credentials, don't waste your time at the TortoiseGit settings. Instead, windows search>Credential Manager> Windows Credentials > find your git entry > Edit.
- 首次登录时,只需按照提示输入您的凭据并保存密码即可。
- 如果您需要更新您的凭据,请不要在 TortoiseGit 设置上浪费时间。相反,Windows 搜索>凭据管理器> Windows 凭据> 找到您的 git 条目 > 编辑。
回答by APP
Try this:
尝试这个:
- Get to your repo folder
- Right click on empty space Tortise Git -> Setting
- Got Credentials (usually located in sidebar under Git Menu)
- In credential Helper, select Wincred, all Windows users
- Hit Apply
- 进入你的 repo 文件夹
- 右键单击空白区域 Tortise Git -> 设置
- Got Credentials(通常位于 Git 菜单下的侧边栏中)
- 在凭据助手中,选择Wincred,所有 Windows 用户
- 点击应用
it will ask for your password only once.
它只会要求您输入一次密码。
回答by rajeshk
Goto the project repo, right click -> 'Git Bash Here'
转到项目仓库,右键单击 -> 'Git Bash Here'
In the git bash windows type
在 git bash windows 类型
cd ~
pwd
i get something like this
我得到这样的东西
/c/Users/<windows_username>
Now copy your public and private keys to this path
现在将您的公钥和私钥复制到此路径
C:\Users\<windows_username>\.ssh
i got the below files there
我在那里得到了以下文件
id_rsa
id_rsa.pub
known_hosts
here
这里
Now when ever it needs to use the credentials it uses these files and prompt for password if needed.
现在,当它需要使用凭据时,它会使用这些文件并在需要时提示输入密码。