另一个 git 进程似乎正在此存储库中运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38004148/
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
Another git process seems to be running in this repository
提问by Matt Corby
I'm trying to learn how to use Git and have created a small project with an HTML, CSS, and Javascript file. I made a branch from my basically empty project and then made some changes to my code. I tried staging the changes but I get the following error message:
我正在尝试学习如何使用 Git,并使用 HTML、CSS 和 Javascript 文件创建了一个小项目。我从我的基本空项目中创建了一个分支,然后对我的代码进行了一些更改。我尝试暂存更改,但收到以下错误消息:
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Granted, I did run into problems trying to commit my empty project earlier and just quit git bash since I didn't know how to get out of where I somehow had gotten.
诚然,我确实在尝试早些时候提交我的空项目时遇到了问题,只是退出了 git bash,因为我不知道如何摆脱我不知何故得到的地方。
Is there any way for me to fix this or should I just start a new repository?
有什么办法可以解决这个问题,还是应该开始一个新的存储库?
回答by Rohit Shedage
Try deleting index.lock
file in your .git
directory.
尝试删除index.lock
目录中的.git
文件。
rm -f .git/index.lock
rm -f .git/index.lock
Such problems generally occur when you execute two git
commands simultaneously; maybe one from the command prompt and one from an IDE.
此类问题一般发生在git
同时执行两个命令时;也许一个来自命令提示符,一个来自 IDE。
回答by M.J
Use the below command in the root directory of the application. This will delete the index.lock file and release the active lock.
在应用程序的根目录中使用以下命令。这将删除 index.lock 文件并释放活动锁。
rm .git/index.lock
回答by Ibn Rushd
Deleting my commit message worked for me.
删除我的提交消息对我有用。
rm .git/COMMIT_EDITMSG
It then said.
它接着说。
fatal: cannot lock ref 'HEAD': Unable to create '.git/refs/heads/[your-branch-name].lock': File exists.
致命:无法锁定引用“HEAD”:无法创建“.git/refs/heads/[your-branch-name].lock”:文件存在。
Do notice that your branch name might be different than mine. You can delete this lock file by doing;
请注意,您的分支名称可能与我的不同。您可以通过执行删除此锁定文件;
rm .git/refs/heads/[your-branch-name].lock
Hope this helps someone.
希望这可以帮助某人。
回答by Matt Corby
Ok I ended up getting it to work by running '$ git rm .git/index.lock'... It's weird because I did that a few times before to no avail but hey computers right?
好吧,我最终通过运行'$ git rm .git/index.lock'让它工作......这很奇怪,因为我之前做过几次都无济于事,但是嘿电脑对吗?
回答by Alex Sed
This happened to me and while sourcetree kept telling me the lock file exists, there was no such a file there for me to remove. So I just checked out another branch and then returned to the original branch and noticed this change fixed the issue.
这发生在我身上,虽然 sourcetree 一直告诉我锁文件存在,但没有这样的文件可供我删除。所以我只是检查了另一个分支,然后返回到原始分支并注意到此更改解决了问题。
回答by Akif
It is similar to above methods but in my case I had several of those
它类似于上述方法,但在我的情况下,我有几个
.git/refs/heads/<branch_name>.lock
and was able to remove all at once by this way
并且能够通过这种方式一次删除所有
find -name "*.lock" -exec xargs rm {} \;
回答by cumanzor
If you are using CocoaPods and at some point botched an update or install (manually killed it or something), try
如果您正在使用 CocoaPods 并且在某个时候搞砸了更新或安装(手动杀死它或其他东西),请尝试
1) Removing the index.lock
file (in .git/index.lock
)
1)删除index.lock
文件(在.git/index.lock
)
2) Remove your Podfile.lock
file.
2) 删除您的Podfile.lock
文件。
3) Do a new pod update
3)做一个新的 pod update
4) Try issuing the git command that was failing (in my case it was a git add .
)
4) 尝试发出失败的 git 命令(在我的例子中是一个git add .
)
回答by Vrezh Gulyan
For me the problem was simpler, this was in source tree so I'm not sure how much it'll apply to regular solutions but I accidentally had my master branch selected trying to make a commit rather than my uncommitted changes.
对我来说,问题更简单,这是在源代码树中,所以我不确定它在多大程度上适用于常规解决方案,但我不小心选择了我的主分支尝试进行提交而不是我未提交的更改。
This wouldn't normally be a problem but I had already preemptively entered a commit message so I could track what I was doing for that little sprint I was on.
这通常不会成为问题,但我已经预先输入了一个提交消息,这样我就可以跟踪我在那个小冲刺中所做的事情。
Basically, I started a commit on the uncommitted branch and was accidentally trying to start another commit on my master branch.
基本上,我在未提交的分支上开始提交,但不小心尝试在我的主分支上开始另一个提交。
回答by Indrajith Ekanayake
If you are windowsuser there will be error 'rm' is not recognized as an internal or external command
. That's because rm is a Linux command. So in windows, you can use below to remove the index.lock
file inside .git
folder
如果您是Windows用户,则会出现错误'rm' is not recognized as an internal or external command
。那是因为 rm 是一个 Linux 命令。因此,在 Windows 中,您可以使用下面的方法删除index.lock
文件.git
夹内的文件
del -f .git/index.lock
回答by Haseeb Iqbal
I got this error while pod update
. I solved it by deleting the index.lock
file in cocoapods
's .git
directory.
我在pod update
. 我通过删除's目录中的index.lock
文件解决了它。cocoapods
.git
rm -f /Users/my_user_name/.cocoapods/repos/master/.git/index.lock
It might help someone.
它可能会帮助某人。