git - 如何修复 Git for Windows 错误 : "could not lock config file C:/file/path/to/.gitconfig: File exists"?

标签 git

在尝试使用我的 GitHub 帐户设置 Git 时,每当我尝试进行全局配置时,以下错误一直存在。

它适用于存储库,但全局不起作用。

这是它的显示方式:

$ git config --global user.name "username"
error: could not lock config file C:/Path/to/.gitconfig: File exists

我在 Windows 10 专业版上使用 Git 2.21.0。

最佳答案

由于您使用的是 Windows 10,如果您的 .gitconfig 位于 C:,则可能会出现问题。如果是这种情况,请尝试以管理员权限运行您的 git bash(右键单击您的可执行文件,选择更多 > 以管理员身份运行)并查看是否有效。您需要管理员权限才能处理 C: 根目录下的文件。那对我有用。

关于git - 如何修复 Git for Windows 错误 : "could not lock config file C:/file/path/to/.gitconfig: File exists"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55327408/

相关文章:

git - 摆脱 "git:/usr/local/lib/libz.so.1: no version information available (required by git)"

java - 禁止使用所有工具进行 SVN check out

ruby - 没有这样的文件或目录 - git ls-files -- WINDOWS

git - msysgit 的麻烦

git - Sourcetree 无法将某些引用推送到存储库

git - .gitignore 文件用于 ssh 目录

git - 如何在 ubuntu 上安装 git bash?

git - 如何应对Git源码控制下的IntelliJ IDEA项目文件不断变化?

difftool 不会显示 Git diff -cc 模式

git - 如何修复 : failed to push some refs to gitlab?