我必须能够在两种情况下执行 Git 命令:
- 在 posh-Git(和 GitHub for Windows UI)中
- 通过在 Windows 资源管理器中双击批处理文件(我创建了一系列批处理文件来简化非技术项目参与者的 Git 使用)
除了推/pull 操作外,一切都完美无缺,那里存在凭据帮助程序问题。使用默认的 GitHub 设置,它在 etc/.gitconfig
中使用 helper = !github –credentials
,远程操作适用于上下文 1 但不适用于上下文 2(它要求提供凭据每次)。如果我将 helper = wincred
添加到 user/.gitconfig
,那么上下文 1 工作正常,上下文 2 工作正常,尽管它首先提示:
github --credentials get: github: command not found
github --credentials store: github: command not found
(我假设它提示是因为它试图使用 GitHub 助手但不能在上下文 2 中使用)但随后继续执行推送:
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 467 bytes | 0 bytes/s, done.
Total 5 (delta 1), reused 0 (delta 0)
...
我可以忍受提示,但问题是每当 GitHub for Windows 启动时,它都会从 user/.gitconfig
中删除 helper = wincred
。
问题是:我可以吗
- 获取上下文 1 以使用 wincred 助手
- 让 GitHub 助手在上下文 2 中工作
- 防止 GitHub for Windows 删除 wincred(虽然这种行为可能是正确的,因为我认为你不应该有两个凭证助手)
- 安装一个可以在两种情况下使用的不同凭证助手
最佳答案
我遇到了类似的问题并联系了 GitHub 支持并得到了这样的回复:
What you're hitting is a configuration sanitizer which GitHub for Windows runs on startup. We've seen significant issues in the past with other Git clients adding invalid/bad configuration values into this file and giving users a bad experience - so we had to take steps to mitigate these issues.
This is opt-in, and you can bypass this by running the following command:
git config --global ghfw.disableverification true
这解决了我的问题
关于GitHub 凭证助手与 wincred 凭证助手冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26681770/