Git Push 避免用户名和密码方法(整理,已验证ok)

来源:互联网 发布:矩阵特征值分解 编辑:程序博客网 时间:2024/06/17 05:49

0 系统环境

Windows平台:
home目录一般在C:\users\Administrator,也可以是你自己创建的系统用户名目录,反正都在C:\users\中。
借助git bash客户端,进入home目录后开始往下操作。

Linux平台:
home目录为~
$ cd ~
进入home目录即可操作,没装git参考安装(http://blog.csdn.net/sinat_36184075/article/details/71512862)

1 创建文件存储Git用户名和密码

$ touch .git-credentials
$ vi .git-credentials
填入此行内容:(替换username和password即可)
https://username:password@github.com


2 添加Git Config 内容

$ git config --global credential.helper store
// 配置一下全局参数
$ vi ~/.gitconfig
// 确认home目录下的.gitconfig文件,会多了一项[credential]。
[credential]
helper = store




大功告成,再次git push的时候就会自动读取账号和密码了,免除频繁输入的问题。
原创粉丝点击