I'm trying to add notepad++ editor in git config using:
git config --global core.editor "C:\LegacyApp\Notepad++\notepad++.exe"
The error I'm getting is:
error: failed to write new configuration file H://.gitconfig.lock
I can't locate .gitconfig.lock file anywhere.
I have already check the ownership rights.
It's worth to point out that my .gitconfig file is empty, I guess this where the problem is coming from, but I have no more ideas how to solve it, except to reinstall my gitBash. Does anyone have any other thoughts of how can I overcome this problem?
Run Git as an administrator.
I had the exact same error trying to enable Git rerere. I'm running windows so I typed Git into the search to bring up the Git Bash program, right clicked and chose run as administrator.
If that does not work try restarting to make sure no other programs write access to the file and try again.
(This should be a comment—it's a guide,not an answer—but I'm too verbose. :-) )
Git writes out a new configuration by copying the existing one to a temporary file, making whatever changes are required along the way. (This is a typical work-flow for such programs: read existing file, make substitutions, write out to temporary file as you work.)
If two users, or two processes for a single user, could perhaps be running simultaneously with both trying to make changes, one process's changes could be lost. Say process A opens the original file and begins making changes while process B also opens the original file and begins making changes. Process A finishes first, replaces the original file with its temporary copy, and quits. Then process B finishes, replaces the original file with its temporary copy, and quits. Process A's changes are now gone.
Git's solution to this is to use a lock: before making any changes, any process must obtain the lock, with the lock being available to only one process at a time. Git combines this with the temporary file itself, by leveraging off the idea that there's an operation that will create a file but fail if the file exists. So if the configuration file is named H:/.gitconfig, the temporary and lock file can be named H:/.gitconfig.lock. This file will automatically be on the same storage device as the configuration file, so at the end, when the temporary file is complete, Git can rename H:/.gitconfig.lock to H:/.gitconfig, which both unlocks the configuration and updates it to the new configuration at the same time.
What this all means is that Git believes the configuration file is named H:/.gitconfig, and it needs permission to create-with-exclusion (the lock action) H:/.gitconfig.lock, but it does not have such permission.
The name H: appears to be a Windows drive specifier. I avoid Windows and don't know if there's a reason you would have your personal Git configuration live in a Windows drive, nor where the Windows-drive permissions might be stored, but that's where to look. Either your configuration should be elsewhere (e.g., H:/yourname) so that permissions are easier to control, or you must fuss with whatever the permissions are on the drive itself, rather than any files within the drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With