[linux服务器git pull/push时提示输入账号密码之免除设置

linux服务器git pull/push时提示输入账号密码之免除设置

1、先cd到根目录,执行git config --global credential.helper store命令

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">[root@iZ25mi9h7ayZ ~]# git config --global credential.helper store</pre>

2、执行之后会在.gitconfig文件中多加红色字体项

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">[user]
name = 天明
email = xxxx@xxxx.com
[credential]
helper = store</pre>

3、之后cd到项目目录,执行git pull命令,会提示输入账号密码。输完这一次以后就不再需要,并且会在根目录生成一个.git-credentials文件

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">[root@iZ25mi9h7ayZ test]# git pull
Username for 'https://git.oschina.net': xxxx@xxxx.com
Password for 'https://xxxx@xxxx.com@git.oschina.net':</pre>

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">[root@iZ25mi9h7ayZ ~]# cat .git-credentials
https://Username:Password@git.oschina.net</pre>

4、之后pull/push代码都不再需要输入账号密码了~

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容