我在git
有我的存储库。在本地副本(我的系统)中,我对其中一个文件进行了一些更改。
我试图将该文件更新到git
存储库。为此我运行以下命令:
git commit -a "text file updated"
但我得到一个错误,如下所示:
$ 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.
这里有什么问题?以及如何解决这个问题?我所做的是将文件从local更新到git的正确方法吗?
问题是你只需要一个锁文件。
您可以删除是否,一旦删除它,获取远程存储库:
# delete the lock file
rm -rf .git/index.lock
# update the local repository
git fetch --all --prune
完成后,使用远程仓库更新本地仓库。
提交您的更改,然后您可以将更改提取到您的分支
# add all the changes
git add .
git commit -m "Message"
# pull the changes which were added to the remote
git pull origin <branch name>
在这种情况下,您应该尝试重新克隆您的项目,一旦您将它复制到第二个克隆,然后提交它们。