如何在 Git 中保存用户名和密码? [英] How can I save username and password in Git?

查看:62
本文介绍了如何在 Git 中保存用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Git Extensions 中自动使用推和拉,Sourcetree 或任何其他 Git GUI,无需在每次都有提示.

I want to use a push and pull automatically in Git Extensions, Sourcetree or any other Git GUI without entering my username and password in a prompt, every time.

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

So how can I save my credentials in Git?

推荐答案

注意:此方法将凭据以纯文本形式保存在您的 PC 磁盘上.您计算机上的每个人都可以访问它,例如恶意 NPM 模块.

Attention: This method saves the credentials in plaintext on your PC's disk. Everyone on your computer can access it, e.g. malicious NPM modules.

运行

git config --global credential.helper store

然后

git pull

提供用户名和密码,这些详细信息稍后会被记住.凭证存储在磁盘上的一个文件中,具有仅用户可读/可写"的磁盘权限.但仍然是明文.

provide a username and password and those details will then be remembered later. The credentials are stored in a file on the disk, with the disk permissions of "just user readable/writable" but still in plaintext.

如果您想稍后更改密码

git pull

会失败,因为密码不正确,git然后从~/.git-credentials文件中删除违规的用户+密码,所以现在重新运行

Will fail, because the password is incorrect, git then removes the offending user+password from the ~/.git-credentials file, so now re-run

git pull

提供一个新密码,使其像以前一样工作.

to provide a new password so it works as earlier.

这篇关于如何在 Git 中保存用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆