您当前的位置: 首页 >  git

任磊abc

暂无认证

  • 1浏览

    0关注

    182博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

git 为特定项目设置用户名/邮箱/密码

任磊abc 发布时间:2021-08-02 16:30:38 ,浏览量:1

1、找到项目所在目录下的 .git,进入.git文件夹,然后执行如下命令分别设置用户名和邮箱

git config user.name "aaaaaaa"
git config user.email "aaaaaaa@qq.com"

然后执行命令查看config文件:cat config

cat config

发现里面多了刚才配置的用户名和邮箱信息user,即成功为该项目单独设置了用户名和邮箱

...
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    name = aaaaaaa
    email = aaaaaaa@qq.com
  • 如果git pull 每次都要求输入用户名和密码,则可以执行如下配置
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

[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/*

最好是两种方法都用,这样的话会是项目提交起来,效果更清晰。避免全局用户名对项目提交进行污染。

关注
打赏
1656830895
查看更多评论
立即登录/注册

微信扫码登录

0.0344s