您的位置:首页 > 运维架构 > Linux

linux下使用git来pull和push时免输账号密码

2017-12-10 00:00 861 查看
在linux环境下将github上的代码pull下来或者将本地代码push到github上时,每次都需要输入账号密码,很麻烦!有什么方法能不输入呢!

1.配置ssh(此处不介绍)

2.增加配置文件

cd到根目录下,执行git config --global credential.helper store命令
$ cd /root/
$ git config --global credential.helper store
$ ll
总用量 112
...
-rw-r--r--  1 root root    81 12月 10 14:47 .gitconfig
...
此时目录下会增加一个.gitconfig文件,这里面就会保存你的账号和用户名等信息。

正常push你的项目代码或pull一次,这一次还是要求你输入账号和密码的。此时根目录下又会生成一个.git-credentials文件,这里面就保存了你的账号和密码信息,可以通过cat查看
$ ll
总用量 116
...
-rw-r--r--  1 root root    81 12月 10 15:07 .gitconfig
-rw-------  1 root root    39 12月 10 14:49 .git-credentials
...


之后你再pull或push就不再需要输入账号密码咯!

ssh配置不成功的同学可以尝试这种方法哦!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux git pull push 免密