Jack Ukleja
Jack Ukleja

Reputation: 13521

"Git error: could not lock config file C:/Users/old_profile/.gitconfig: No such file or directory" after profile migration

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.

For some git commands I get the error:

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

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.

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.

Upvotes: 8

Views: 26309

Answers (4)

Yan Los
Yan Los

Reputation: 1

My problem was the same:

“Git error: could not lock config file C:/<Name_file>/.gitconfig: No such file or directory”

  1. I saw that "C:/<...>/" no any files, and I found file ".gitconfig" in C:/Users/profile/.gitconfig
  2. I did copy-paste .gitconfig to C:/<...> and reload PC, after Run git as Administrator and all worked correct.

Upvotes: 0

Chiramisu
Chiramisu

Reputation: 4726

In WSL / bash

Use sudo to set values. This should only apply to the --system scope.

sudo git config --system diff.tool p4merge

In Cmd / PowerShell

Run as Administrator to set values. This is because the gitconfig file (probably located at: C:\Program Files\Git\mingw64\etc\) is protected.

Only SYSTEM and COMPUTER\Administrators have Modify rights. The rest of the ACLs have Read and Read & execute rights only.

ACL List

Upvotes: 0

Jerin
Jerin

Reputation: 1274

I faced similar issue.

Error: could not lock config file 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.

Upvotes: 10

Jack Ukleja
Jack Ukleja

Reputation: 13521

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.

Upvotes: 1

Related Questions