53

I am using git-scm and tried to push to a repository. Upon doing so, I was greeted with the following message:

fatal: unable to get credential storage lock: File exists

While the push did end up pushing successfully, I was wondering why this error appeared. It is still doing this, and was not doing this before. Any help is appreciated. Thanks!

sschale
  • 5,168
  • 3
  • 29
  • 36
J. Doe
  • 531
  • 1
  • 4
  • 3
  • 5
    I found that there is a file `/c/Users/USERNAME/.git-credentials.lock` - but when I delete it I get an assertion error next time I run git, and there is a new lock file. Which leads to a new "lock: File exists" error. I also found that I had two (differing) settings for `credential.store`, one in my home directory, and another one in `/C/Program\ Files/Git/mingw64/etc/gitconfig`. Removing the latter changed nothing, even though `git config -l` now only shows one setting. So to me this issue remains a mystery. I found this: https://github.com/git-for-windows/git/issues/766 – Mörre Jun 08 '16 at 14:20
  • 1
    this happened to me after "cancel" one git add or commit. if you press CTRL+C at git bash. – Joe RR Jul 06 '16 at 13:49

9 Answers9

40

I had the same issue today. It turned out that I somehow had two configs for credential.helper. Use git config --list to check whether your have multiple credential.helper="XXX".

In my case, I had credential.helper=manager in global config and credential.helper=store in local config.

I removed the local one in path-to-git-project/.git/config and solved the problem.

Tobias
  • 7,282
  • 6
  • 63
  • 85
Zhe He
  • 669
  • 6
  • 7
  • For me I think this has something to do with the new credential manager stuff with the latest versions of Git for Windows. The old paradigm was to set credential.helper to store and use auth keys... now it seems Git for Windows will manage your live account internally by default – phil Jun 29 '16 at 14:45
  • 8
    This fixed my problem. I also found `git config --list --show-origin` to be useful, and `git config --WHICH --unset credential.helper` where WHICH is the offending entry location ie `local`, `global`, or `system`. – Oliver Feb 24 '19 at 20:47
14

try to configure your credential helper without using --global

git config credential.helper wincred
Khaled AbuShqear
  • 1,230
  • 14
  • 24
7

The error message comes from git credential-store (click for documentation page). It indicates that another instance of the credential storage program is currently running and has locked the file that (insecurely, in plain-text) stores your password.

If no other instance of git credential-store is actually running, the lock file is no doubt left over from a previous run, and you can simply remove it. Unfortunately the program fails to tell you the location of the specific credentials file (but see the documentation for likely locations).

torek
  • 448,244
  • 59
  • 642
  • 775
1

I've had a hard time figuring out where the lock file was. On Linux, just use strace, but don't forget to follow child processes with the -f option:

strace -f -eopen git credential-store --file=~/mystore store < creds
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
open("/dev/null", O_RDWR)               = 3
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
open("/home/g179531/.gitconfig", O_RDONLY) = 3
Process 8269 attached
[pid  8269] open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
[pid  8269] open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
[pid  8269] open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
[pid  8269] open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
[pid  8269] open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
[pid  8269] open("~/mystore.lock", O_RDWR|O_CREAT|O_EXCL, 0666) = -1 ENOENT (No such file or directory)
fatal: unable to get credential storage lock: No such file or directory
[pid  8269] +++ exited with 128 +++
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8269, si_status=128, si_utime=0, si_stime=0} ---
+++ exited with 128 ++

The last file that the program tried to open before printing the error is the lock file. In my case, it's ~/mystore.lock.

liberforce
  • 11,189
  • 37
  • 48
1

in my case on windows there was a git credentials .lock added in my c:\users\xxxx directory where all global git config lives.

i deleted the lock file which also removed the git credentials file that stored my password in clear text

Sonic Soul
  • 23,855
  • 37
  • 130
  • 196
1

This is what fixed the problem for me on Window: I run git config --list --show-origin and find all credential.helper=XXX configs, then go to all directories containing those .gitconfig files and change that setting to credential.helper=store

Also, your local config should be helper = manager too: go to .git/config and add/modify this line like this:

[credential]
helper = manager
1

I followed the instructions listed before in this thread and excecute this command: git config --list --show-origin, after that it shows the locations where git has any type of configuration, like this: file:"C:\ProgramData/Git/config" , "file:C:/Users/User/.gitconfig" , "file:.git/config".

Then I dive into the folder file:C:/Users/User/ and remove the file called: .git-credentials.lock , then excecute "git pull origin branch" again and it works !!

Rene Arteaga
  • 334
  • 3
  • 6
0

execute C:\Program Files\Git\mingw64\libexec\git-core>git-credential-manager.exe remove

  • OP was wondering about the cause of the error message they got, this doesn't answer their question (also we don't know if they are using Windows or another OS). – Kay Jul 25 '18 at 17:22
-1
  • Open SmartGit then go to Edit -> Preferences -> Hosting Providers.
  • Remove Existing Provider, then click on Add Button.
  • Select "BitBucket" from Down and Click on "Generate Token" button.
  • Login by Your "BitBucket" ID and Password then copy the generate code.
  • Paste the code in Smart Git and click on "Add Button".
Ahmer Khan
  • 57
  • 10