如果我设置
git config --global credential.username my_username
使用 --local
选项覆盖全局设置后,仍然无法为一个特定的仓库使用本地凭据来提交或推送。如何解决这个问题?
git config --global credential.username my_username
使用 --local
选项覆盖全局设置后,仍然无法为一个特定的仓库使用本地凭据来提交或推送。如何解决这个问题?
对我来说,仓库本地配置不起作用。经过从stackoverflow尝试了各种方法之后,最终通过从ssh切换到https并使用credential.helper使其工作:
步骤1,将git远程更改为https:
$ git remote -v
git@github.com:#####/###.git (push)
$ git remote rm origin
$ git remote add origin https://username@github.com/######/###.git
步骤 2: 让 credential.helper 帮助记住密码,避免重复烦人的询问。
$ git config --global credential.helper cache
$ git config --global credential.helper 'cache --timeout 7200'
默认情况下,凭据将保存在 ~/.git-credentials 文件中。该文件将被创建并写入。
但请注意,使用此帮助程序会将您的密码明文存储在磁盘上,仅受文件系统权限保护。如果这可能不是可接受的安全权衡,请注意。
如果没有为网络身份验证设置用户名,则默认使用此用户名
可能您已经在--global
上配置了user.name
,因此--local
上的credential.username
未被使用。请尝试以下操作:
git config --local user.name my_username
.git/config
文件已经更新了吗? - chepner--local
选项设置的username
。 - joval~/.gitconfig
和myproject/.git/config
更加方便。它会准确地显示您设置的选项,而且语法相当自解释。 - cmaster - reinstate monica