git免密

一、创建单密码存储(git-credential-helper)

在工作目录下创建.git-credentials文件:

vim .git-credentials

输入:https://{username}:{password}@github.com

注:1.如果远程仓库是用http协议,则输入 http://{username}:{password}@github.com

        2.如果用户名密码有特殊字符,则用双引号

创建或者添加~/.gitconfig文件:

git config --global credential.helper store

重新拉取一次代码,正确输入一次用户名/密码后,后面就可以免密了!!

二、多密码存储(git-credential-store)

git-credential-store是git提供的另一个工具,可以用来管理用户名和密码,并将它们存储在本地的文件中。相比于git-credential-helper,git-credential-store在用户交互中更加便捷。要使用git-credential-store来配置多个用户名和密码。

创建~/.git-credentials-store文件

vi ~/.git-credentials-store

protocol=https
host=github.com
username=your_username
password=your_password

protocol=https
host=your-git-url.com
username=your_username
password=your_password

#需要将上面的`your_username`和`your_password`替换为实际的用户名和密码,`github.com`和`your-git-url.com`替换为对应的远程仓库地址

重新拉取一次代码,正确输入一次用户名/密码后,后面就可以免密了!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值