Git提交记住用户名和密码、清除用户名密码

2018-08-10 9299点热度 1人点赞 0条评论

原文链接

Git提交记住用户名和密码
git清除用户名密码

Git提交记住用户名和密码

Https记住密码

永久记住密码

git config --global credential.helper store

会在用户主目录的.gitconfig文件中生成下面的配置。

[credential]
    helper = store

如果没有--global,则在当前项目下的.git/config文件中添加。

当然,你也可以直接复制上面生成的配置到配置文件中。

临时记住密码

默认记住15分钟

git config –global credential.helper cache

下面是自定义配置记住1小时:

git config credential.helper 'cache –timeout=3600'

SSH记住密码

可以从一个已有的SSH KEY来记住密码,会在用户主目录下的known_hosts生成配置。
把ssh key添加到ssh-agent

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

如添加过程:

$ eval $(ssh-agent -s)
Agent pid 54188

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/Administrator/.ssh/id_rsa:
Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa)

git清除用户名密码

问题:
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'http://********

解决方案:

git config --system --unset credential.helper

之后再进行git操作时,弹出用户名密码窗口,输入即可

王显锋

激情工作,快乐生活!

文章评论