jov*_*val 6 git config credentials
如果我设置
git config --global credential.username my_username
Run Code Online (Sandbox Code Playgroud)
选项,然后使用--local选项覆盖它的一个存储库对其没有任何区别 - 它在尝试提交或推送时仍然使用全局凭据。我怎样才能改变这个?
回购本地配置对我不起作用。在从 stackoverflow 尝试了各种方法之后,最终它通过从 ssh 切换到 https 并使用credential.helper 来工作:
第 1 步,将 git remote 从 ssh 更改为 https:
$ git remote -v
git@github.com:#####/###.git (push)
$ git remote rm origin
$ git remote add origin https://username@github.com/######/###.git
Run Code Online (Sandbox Code Playgroud)
第2步,让credential.helper帮助记住密码,避免烦人的重复询问。
$ git config --global credential.helper cache
$ git config --global credential.helper 'cache --timeout 7200'
Run Code Online (Sandbox Code Playgroud)
默认情况下,凭据将保存在 ~/.git-credentials 中。它将被创建和写入。
但请注意,使用此助手会将未加密的密码存储在磁盘上,仅受文件系统权限保护。如果这可能不是可接受的安全权衡。
| 归档时间: |
|
| 查看次数: |
5243 次 |
| 最近记录: |