致命:无法获取凭证存储锁:文件存在

时间:2016-05-29 03:21:43

标签: git

我正在使用git-scm并试图推送到存储库。在这样做的时候,我收到了以下消息:

fatal: unable to get credential storage lock: File exists

虽然推送最终成功推进,但我想知道为什么会出现这个错误。它仍在这样做,之前没有这样做过。任何帮助表示赞赏。谢谢!

9 个答案:

答案 0 :(得分:30)

我今天遇到了同样的问题。事实证明,我以某种方式为credential.helper配置了两个配置。使用git config --list检查您是否拥有多个 credential.helper =“XXX”

就我而言,我在全局配置中使用了credential.helper = manager,在本地配置中使用了credential.helper = store。

我删除了 path-to-git-project / .git / config 中的本地文件并解决了问题。

答案 1 :(得分:6)

尝试在不使用--global

的情况下配置您的凭证助手
git config credential.helper wincred

答案 2 :(得分:4)

错误消息来自git credential-store (click for documentation page)。它表示凭据存储程序的另一个实例当前正在运行,并锁定了(不安全地,以纯文本格式)存储密码的文件。

如果git credential-store的其他实例实际上没有运行,那么锁定文件无疑会从之前的运行中遗留下来,您只需将其删除即可。遗憾的是,该程序未能告诉您特定凭证文件的位置(但请参阅可能位置的文档)。

答案 3 :(得分:1)

我很难搞清楚锁文件的位置。 在Linux上,只需使用strace,但不要忘记使用-f选项跟踪子进程:

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 ++

程序在打印错误之前尝试打开的最后一个文件是锁定文件。就我而言,它是~/mystore.lock

答案 4 :(得分:1)

这是在Window上为我解决问题的原因: 我运行git config --list --show-origin并找到所有credential.helper = XXX配置,然后转到包含那些.gitconfig文件的所有目录,并将该设置更改为credential.helper = store

此外,您的本地配置也应该是helper = manager:转到.git / config并添加/修改此行,如下所示:

[credential]
helper = manager

答案 5 :(得分:0)

在我的Windows案例中,我的c:\ users \ xxxx目录中添加了一个git凭据.lock,其中所有全局git配置都存在。

我删除了锁定文件,该文件还删除了以明文

存储密码的git凭证文件

答案 6 :(得分:0)

执行 C:\ Program Files \ Git \ mingw64 \ libexec \ git-core> git-credential-manager.exe删除

答案 7 :(得分:0)

  • 打开SmartGit,然后转到“编辑”->“首选项”->“托管服务提供商”。
  • 删除现有提供程序,然后单击“添加”按钮。
  • 从下拉菜单中选择“ BitBucket”,然后单击“生成令牌”按钮。
  • 通过您的“ BitBucket” ID和密码登录,然后复制生成的 代码。
  • 将代码粘贴到Smart Git中,然后单击“添加按钮”。

答案 8 :(得分:0)

我按照此线程中之前列出的说明执行此命令:git config --list --show-origin,之后它会显示 git 具有任何类型配置的位置,如下所示:file:"C:\ProgramData/Git/ config" , "file:C:/Users/User/.gitconfig" , "file:.git/config"。

然后我深入文件夹 file:C:/Users/User/ 并删除名为:.git-credentials.lock 的文件,然后再次执行“git pull origin branch”,它工作了!!

相关问题