默认情况下,当你通过http的方式拉取远程仓库时,需要进行如下操作,

/tmp$ git clone http://172.18.153.242/linux/test.git
Cloning into 'test'...
Username for 'http://172.18.153.242': xiaoqiang.lai
Password for 'http://xiaoqiang.lai@172.18.153.242': 
remote: Enumerating objects: 297, done.
remote: Counting objects: 100% (297/297), done.
remote: Compressing objects: 100% (146/146), done.
^Cceiving objects:  53% (5324/9982), 15.63 MiB | 9.55 MiB/s 

如上内容,通过http的方式进行拉取公司内部服务器下的git代码仓库时,需要手动输入Username和Password,而且再下一次进行代码同步时同样还是要手动输入Username、Password,那么如何去除这种重复性的动作呢??

解决方法:

在进行了一次基于http进行远程仓库的拉取后,
执行如下命令,进行特定ip地址访问的Username、Password

git config --global credential.helper store

在成功执行以上指令后,会在你的Home目录下生成如下一个配置文件,

~/.git-credentials

本质上就是在通过http进行远程仓库操作时,自动添加上Username、Password

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐