配置文件迁移后“Git 错误:无法锁定配置文件 C:/Users/old_profile/.gitconfig: No such file or directory”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42917131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Git error: could not lock config file C:/Users/old_profile/.gitconfig: No such file or directory" after profile migration
提问by Hyman Ukleja
I have an interesting error that keeps coming up when using git for windows (version 2.12.0.windows.1). I recently migrated my windows profile directory from one location to another.
使用 git for windows(版本 2.12.0.windows.1)时,我有一个有趣的错误不断出现。我最近将我的 Windows 配置文件目录从一个位置迁移到另一个位置。
For some git commands I get the error:
对于某些 git 命令,我收到错误消息:
error: could not lock config file C:/Users/<my old profile>/.influxdb/.gitconfig: No such file or directory
error: could not lock config file C:/Users/<my old profile>/.influxdb/.gitconfig: No such file or directory
error: could not lock config file C:/Users/<my old profile>/.influxdb/.gitconfig: No such file or directory
error: could not lock config file C:/Users/<my old profile>/.influxdb/.gitconfig: No such file or directory
Note: This error always comes up twice, for example if I try to do git config --global diff.tool p4merge
注意:此错误总是出现两次,例如,如果我尝试这样做 git config --global diff.tool p4merge
What is interesting is that this folder it's looking for doesn't exist, and if i use git config -l --show-origin
to see where git is getting it's settings, it makes no mention of this path, and if I look inside any CONFIG
files I can see no reference to this non-existant path.
有趣的是,它正在寻找的这个文件夹不存在,如果我git config -l --show-origin
用来查看 git 在哪里获取它的设置,它没有提到这个路径,如果我查看任何CONFIG
文件,我看不到对此的引用不存在的路径。
Where is git storing a reference to this old path? I need to update it as I think this error is stopping some commands working.
git 在哪里存储对这条旧路径的引用?我需要更新它,因为我认为此错误正在停止某些命令的工作。
回答by Jerin
I faced similar issue.
我遇到了类似的问题。
Error: could not lock config file C:/.gitconfig:
错误:无法锁定配置文件 C:/.gitconfig:
Solution:I had a system environment variable (Home= C:\
) in my computer and it caused this issue. Deleted it and everything started working.
解决方案:我的计算机中有一个系统环境变量 ( Home= C:\
),它导致了这个问题。删除它,一切开始工作。
回答by Hyman Ukleja
This was being caused by bad paths in my environment variables (due to the profile migration).
这是由我的环境变量中的错误路径引起的(由于配置文件迁移)。
I opened up System Properties -> Environment Variables, and updated all references to C:\Users\<old_profile>
with the new one.
我打开了 System Properties -> Environment Variables,并C:\Users\<old_profile>
用新的引用更新了所有引用。
回答by Nitin Anand
this can be due to using multiple git account on visual studio. Check if you are logged in with correct credentials.
这可能是由于在 Visual Studio 上使用了多个 git 帐户。检查您是否使用正确的凭据登录。
回答by Chiramisu
In WSL / bash
在 WSL/bash 中
Use sudoto set values. This should only apply to the --system
scope.
使用 sudo设置值。这应该只适用于--system
范围。
sudo git config --system diff.tool p4merge
In Cmd / PowerShell
在 Cmd / PowerShell 中
Run as Administratorto set values. This is because the gitconfig
file (probably located at: C:\Program Files\Git\mingw64\etc\
) is protected.
以管理员身份运行以设置值。这是因为gitconfig
文件(可能位于C:\Program Files\Git\mingw64\etc\
:)受到保护。
Only SYSTEM
and COMPUTER\Administrators
have Modify
rights. The rest of the ACLs have Read
and Read & execute
rights only.
只有SYSTEM
和COMPUTER\Administrators
有Modify
权利。其余的 ACL仅具有Read
和Read & execute
权限。