抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

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

1
[  root@iZ25mi9h7ayZ ~]# git config --global credential.helper store

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

1
2
3
4
5
[  user]
name = 天明
  email = xxxx@xxxx.com
[  credential]
  helper = store

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

1
2
3
[  root@iZ25mi9h7ayZ test]# git pull
Username for 'https://git.oschina.net': xxxx@xxxx.com
Password for 'https://xxxx@xxxx.com@git.oschina.net':
1
2
[root@iZ25mi9h7ayZ ~]# cat .git-credentials
https://Username:Password@git.oschina.net

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

评论