我们如果没有为项目设置用户名密码,那么每次提交都会有提示账号和密码输入:
1.找到你项目的半隐藏文件.git文件夹,通常只要git init 就会生成这样一个文件夹,现在双击进入文件夹:
git config user.name "qianxiao"
2.我们执行如下代码查看git配置文件:
cat configLinux用法
windows 直接记事本打开即可
3.显示如下配置:
显示如下内容:
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = http://gitee.com/xxx/object.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "room"] remote = origin merge = refs/heads/room [user] name = qianxiao
看到最后一行,成功为当前项目设置了git用户名
4.然后执行如下代码新增配置:
git config credential.helper store
5.再执行cat config查看配置:
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = http://gitee.com/xxx/object.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "room"] remote = origin merge = refs/heads/room [user] name = qianxiao [credential] helper = store
看到最后一行新增如上helper;