`Git`-更新并给出错误[.git/index.lock':文件存在.] [英] `Git` - update giving the error [.git/index.lock': File exists.]

查看:241
本文介绍了`Git`-更新并给出错误[.git/index.lock':文件存在.]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存储库位于git中.在本地副本(我的系统)中,我对其中一个文件进行了一些更改.

I have my repository in the git. in the local copy ( my system ) I have made some changes on one of the files.

,我尝试将该文件更新为git存储库.为此,我正在运行以下命令:

and I tried to update that file to git repository. for that I am running the following command :

git commit -a "text file updated"

但是我遇到这样的错误:

But i am getting a error as like this:

$ git commit -a
fatal: Unable to create 'D:/Projects/gitProjects/color-palette/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git process is running and remove the file manually to continue.

这是什么问题?以及如何解决这个问题? 我要做的是将文件从本地更新到git的正确方法吗?

what is the problem here? and how to solve this? what I do is the correct way to update the file from local to git right?

推荐答案

问题是您只是拥有一个锁定文件.

The problem is that you simply have a lock file.

您可以删除是否以及一旦删除它就获取远程存储库:

You can delete if and once you delete it fetch the remote repository:

# delete the lock file
rm -rf .git/index.lock

# update the local repository
git fetch --all --prune

执行此操作后,本地存储库将使用远程存储库进行更新.

Once you do it your local repo is updated with the remote repo.

提交更改,然后将更改拉到分支中

Commit your changes and then you can pull the changes into your branch

# add all the changes
git add . 

git commit -m "Message"

# pull the changes which were added to the remote
git pull origin <branch name>


如果删除索引不起作用怎么办?

在这种情况下,您应该尝试重新克隆您的项目,并在获得项目后将所需的更改文件复制到第二个克隆中,然后提交它们.


What if the deletion of the index does not work?

In this case you should try to re-clone your project and once you have it copy the desired changes files onto the second clone and then commit them.

这篇关于`Git`-更新并给出错误[.git/index.lock':文件存在.]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆