我想在GitExtensions、Sourcetree或任何其他GitGUI中自动使用推拉,每次都不需要在提示中输入用户名和密码。

那么我如何在Git中保存我的凭据?


当前回答

只需将您的凭据放入URL,如下所示:

https://Username`**:**`Password`**@**`github.com/myRepoDir/myRepo.git`

您可以这样存储:

git remote add myrepo https://Userna...

…使用它的示例:

git push myrepo master`

现在就是列出URL别名:

git remote -v

…以及删除其中一个的命令:

git remote rm myrepo

其他回答

只需将您的凭据放入URL,如下所示:

https://Username`**:**`Password`**@**`github.com/myRepoDir/myRepo.git`

您可以这样存储:

git remote add myrepo https://Userna...

…使用它的示例:

git push myrepo master`

现在就是列出URL别名:

git remote -v

…以及删除其中一个的命令:

git remote rm myrepo

对于Windows用户,请查看.gitconfig文件并检查为凭据助手配置了什么。如果您有以下内容。。。

[凭证“helperselector”]selected=绞车

您将在Windows凭据管理器中找到凭据。

您可以在那里编辑凭证。

注意:Wincred已被弃用,请参阅。。。

https://github.com/Microsoft/Git-Credential-Manager-for-Windows#notice-该项目不再处于警告状态

因此,您可能需要重新配置Git以使用内置的Git凭据管理器。。。

git config --global credential.helper manager

您可以使用git凭据存储将未加密的密码存储在磁盘上,仅受文件系统权限的保护。

实例

git config credential.helper store
git push http://example.com/repo.git

Username: <type your username>
Password: <type your password>

[Several days later]

git push http://example.com/repo.git

[Your credentials are used automatically]

您可以检查存储在文件~/.git凭据中的凭据。

有关更多信息,请访问git credential store-Helper将凭据存储在磁盘上。

如果您正在Windows上使用Git凭据管理器。。。

git-config-l应该显示:

credential.helper=manager

但是,如果没有提示您输入凭据,请执行以下步骤:

从“开始”菜单打开“控制面板”选择用户帐户在左侧菜单中选择管理凭据删除与Git或GitHub相关的任何凭据

如果您有代理并且Git服务器位于内部网络上,请确保您没有设置HTTP_PROXY、HTTPS_PROXY、NO_PROXY环境变量。

您还可以使用gitgui测试Git fetch/push/pull,gitgui链接到C:\Users\<username>\AppData\Local\Programs\Git\mingw64\libexec\Git-core中的凭据管理器二进制文件

以前的答案对我来说都不管用。每次我想取东西或拉东西时,我都会得到以下答案:

输入密钥“/Users/myusername/.ssh/id_rsa”的密码:


适用于Mac

我可以通过以下方式阻止它询问我的密码:

通过运行:vi~/.ssh/config打开config添加了以下内容:UseKeychain yes保存并退出:按Esc,然后输入:wq!


对于Windows

我能够使用此Stack Exchange帖子中的信息使其发挥作用:如何避免每次推到Bitbucket时被询问密码