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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37505843/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:13:28  来源:igfitidea点击:

fatal: unable to get credential storage lock: File exists

git

提问by J. Doe

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

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

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!

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

回答by Zhe He

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

我今天遇到了同样的问题。事实证明,我不知何故有两个 credential.helper 配置。使用git config --list检查是否您有多个credential.helper =“XXX”

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

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

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

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

回答by Khaled AbuShqear

try to configure your credential helper without using --global

尝试在不使用 --global 的情况下配置您的凭证助手

git config credential.helper wincred

回答by torek

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.

错误消息来自git credential-store(单击文档页面)。它表示凭证存储程序的另一个实例当前正在运行并且已锁定(不安全地,以纯文本形式)存储您的密码的文件。

If no other instance of git credential-storeis 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).

如果git credential-store实际上没有其他实例在运行,那么锁定文件无疑是上次运行遗留下来的,您可以简单地将其删除。不幸的是,该程序无法告诉您特定凭据文件的位置(但请参阅文档以了解可能的位置)。

回答by liberforce

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 -foption:

我很难弄清楚锁文件在哪里。在 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 ++

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

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

回答by Sonic Soul

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

就我而言,在 Windows 上,在我的 c:\users\xxxx 目录中添加了一个 git 凭据 .lock,所有全局 git 配置都位于该目录中。

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

我删除了锁定文件,该文件也删除了以明文形式存储我的密码的 git 凭据文件

回答by Carmen Santacruz

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

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

回答by Ahmer Khan

  • 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".
  • 打开 SmartGit,然后转到 Edit -> Preferences -> Hosting Providers。
  • 删除现有提供程序,然后单击添加按钮。
  • 从下选择“BitBucket”并点击“Generate Token”按钮。
  • 使用您的“BitBucket”ID 和密码登录,然后复制生成代码。
  • 将代码粘贴到 Smart Git 中,然后单击“添加按钮”。