如何使用GIT为指定项目单独设置用户名和密码。
希望项目提交起来,效果更清晰。避免全局用户名对项目提交进行污染。

使用GIT为指定项目单独设置用户名和密码
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
关注
1、找到项目所在目录下的 .git,进入.git文件夹,然后执行如下命令分别设置用户名和邮箱
git config user.name "aaaaaaa" git config user.email "aaaaaaa@qq.com"
然后执行命令查看config文件:cat config
cat config
会发现里面多了刚才配置的用户名和邮箱信息user,即成功为该项目单独设置了用户名和邮箱
如果git pull 每次都要求输入用户名和密码,则可以执行如下配置... [branch "master"] remote = origin merge = refs/heads/master [user] name = aaaaaaa email = aaaaaaa@qq.com git config credential.helper store
执行后, cat config查看,则多了credential的内容:
[user] name = aaaaaaa email = aaaaaaa@qq.com [credential] helper = store
然后再回到项目目录下执行git pull/push,根据提示输入用户名和密码,输入正确后,以后再执行git pull/push 就不用输入用户名和密码了
或者在
2、.git文件夹下的config的文件,在加上用户名aaaaaaa
url = https://aaaaaaa@github.com/IBAX-io/ibax.io.git@github.com/IBAX-io/ibax.io.git
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = https://aaaaaaa@github.com/aaa-io/aaa.io.git fetch = +refs/heads/*:refs/remotes/origin/*
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用