方案一:
- 在你的用户根目录下新建一个文本文件, 名曰.git-credentials
在终端输入$touch .git-credentials
- 然后编辑刚刚创建的文件
在终端输入$vim .git-credentials
- 然后输入
https:{username}:{password}@xxxxxx.com
@后面是输入你的git做操作需要密码的地址
当然上述{username}和{password}要换成你的地址的账号名和密码
然后保存
执行命令git config --global credential.helper store
上述命令会在~/.gitconfig文件末尾添加如下配置:
[credential]
helper = store
方案二:
在命令行输入命令:
git config --global credential.helper store
☞ 这一步会在用户目录下的.gitconfig文件最后添加:
[credential]
helper = store
现在push你的代码 (git push), 这时会让你输入用户名密码, 这一步输入的用户名密码会被记住, 下次再push代码时就不用输入用户名密码啦!
☞这一步会在用户目录下生成文件.git-credential记录用户名密码的信息.
☞ git config --global 命令实际上在操作用户目录下的.gitconfig文件, 我们cat一下此文件(cat .gitconfig), 其内容如下:
[user]
name = alice
email = alice@aol.com
[push]
default = simple
[credential]
helper = store