美文网首页
GIT切换用户

GIT切换用户

作者: PHP的点滴 | 来源:发表于2021-11-09 14:49 被阅读0次

    背景

    之前测试环境发布代码是通过git拉取的;所以有些项目是同事(已停用)用自己的git账号发布的!
    为了统一,就创建了一个专门用来发布的git账号

    部署报错

    按照网上的教程进行以下设置(原来的账号停用)

      git config --global user.name "deploy" 
      git config --global user.email "123456" 
    
      git config --local user.name "deploy" 
      git config --local user.email "123456" 
    

    设置后,再拉去代码的时候报错

    $ git pull
    remote: User permission denied
    fatal: unable to access 'http://git.xxxxx.com/a.git/': The requested URL returned error: 403
    

    折腾了好一会都没有解决

    正确解决方式

    1.取消原来密码的信任

    git config --global --unset credential.helper
    

    2.删除原来保存的密码信息

    vim  ~/.git-credentials
    

    删除掉被保存的账号密码
    3.执行保存记住密码操作

    git config --global credential.helper store
    

    4.正常操作

    git pull 
    或者
    git clone
    

    按照提示,输入正确的账号密码即可

    相关文章

      网友评论

          本文标题:GIT切换用户

          本文链接:https://www.haomeiwen.com/subject/riwmzltx.html