第一步:添加目标地址、用户名、密码、到系统默认文件路径(默认是 ~/.git-credentials
)
cat ~/.gitconfig
cd rootgitee.com
ls -a #查看所有文件:隐藏文件、可见文件
vim .git-credentials
- # 如果是gitee.com就https://user:password@gitee.com;
- # 如果是github.com就https://user:password@github.com;
- 其中user是你登陆gitee.com或者github.com的用户名,如果用户名是邮箱登陆有@,请转为%40,password是你的登陆密码,例如我的
https://zhiboqingy%40sina.com:123456@gitee.com
查看 cat .git-credentials
显示 https://zhiboqingy%40sina.com:123456@gitee.com
第二步:存储默认git-credentials
配置文件
git config --global credential.helper store # “store” 模式可以接受一个 --file <path>
参数,可以自定义存放密码的文件路径(默认是 ~/.git-credentials
)
cat ~/.gitconfig
显示
[credential]
helper = store
第三步:免密生效检查
git clone https://gitee.com/zhiboqingy/code.git
cd code
git branch -a
git checkout develop
git fetch
git pull
以上操作,均未添加用户名和密码