我想在GitExtensions、Sourcetree或任何其他GitGUI中自动使用推拉,每次都不需要在提示中输入用户名和密码。
那么我如何在Git中保存我的凭据?
我想在GitExtensions、Sourcetree或任何其他GitGUI中自动使用推拉,每次都不需要在提示中输入用户名和密码。
那么我如何在Git中保存我的凭据?
当前回答
对于Windows用户,这种方式将起作用:
注意:如果您为GitHub启用了双因素身份验证,请暂时禁用它
步骤1转到控制面板→ 用户帐户→ 凭据管理器→ Windows凭据步骤2转到“通用凭据”部分→ 添加通用凭据步骤3-填写字段Internet或网络地址:git。https://github.com用户名:您的GitHub用户名密码:您的GitHub用户名现在单击“确定”。这将将您的GitHub帐户的密码和用户名保存到本地计算机
其他回答
对于有相同问题的gitlab用户-
您可以设置一个部署令牌来克隆或从存储库中提取(不能使用部署令牌将代码推送到repo)。
在这里,您可以了解有关gitlab部署令牌的更多信息:https://docs.gitlab.com/ee/user/project/deploy_tokens/index.html
创建部署令牌后,请使用以下方法克隆回购:
git clone https://${username}:${deploy_token}@gitlab.com/yourusername/yourreponame.git
我认为这种方法比全局保存git用户名和git密码更好(例如,在远程共享计算机中可能不安全)
只需使用
git config --global credential.helper store
然后做数字拉动。它将要求输入用户名和密码。从现在起,它将不会提供任何用户名和密码提示。它将存储详细信息。
只需将您的凭据放入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 config --global user.name "fname lname"
git config --global user.email "example@gmail.com"
git config --global user.password "secret"
获取特定设置,
git config --global --get user.name
git config --global --get user.email
git config --global --get user.password
正在获取所有Git设置:
git config --list --show-origin