I am new to git
and was trying to commit, but I got stuck in what looked like vi
which I'm not familiar with. I managed to get out of it, but I think I got out the wrong way because my git status says "changes not staged," but I still can't try again. Could someone tell me what I can do to fix the still hanging process and commit my changes?
我是git的新手,试图提交,但是我被困在了我不熟悉的vi中。我设法摆脱了它,但我想我走错了路,因为我的git状态说“变化不是分阶段的”,但是我仍然不能再尝试。有人能告诉我,我能做些什么来修复仍然挂着的流程并提交我的更改吗?
here is the error
这是错误的
fatal: Unable to create '/.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.
not i took out the full path
我没有走完整的路。
As always thanks for your help.
谢谢你的帮助。
4 个解决方案
#1
11
Assuming you're not doing anything with git at the moment (i.e., not doing a push or pull or running a git script in the repository, for any reason), you could just remove the lock file manually and try again.
假设你现在没有在git中做任何事情(例如:因为任何原因,您都可以手动删除锁文件,然后再试一次。
Also, git expects a "commit message" describing your changes. Assuming you don't want an editor to open, you can provide an inline message using the -m
option:
另外,git希望“提交消息”描述您的更改。假设您不希望编辑器打开,可以使用-m选项提供内联消息:
git commit -am "Changed this, that, and the other thing"
#2
12
Removing index.lock file manually from .git directory worked.
删除索引。手动从.git目录手动锁定文件。
or
或
From command line:
从命令行:
$ rm -rf .git/index.lock
Note: Make sure that only one index file exist on .git directory
注意:确保在.git目录中只存在一个索引文件。
#3
1
Note the message will improve and be more explicit with git 2.9 (June 2016), in order to invite you to consider all the causes before removing that lock yourself.
请注意,该消息将会得到改善,并在git 2.9(2016年6月)中更加明确,以便在删除锁之前邀请您考虑所有原因。
See commit aed7480, commit 3030c29 (01 Mar 2016) by Matthieu Moy (moy
).
Helped-by: Moritz Neeb (zormit
).
(Merged by Junio C Hamano -- gitster
-- in commit 3b8c4b7, 03 Apr 2016)
见提交aed7480,由Matthieu Moy (Moy)提交3030c29(2016年3月01日)。得益于:莫里茨Neeb(zormit)。(由Junio C . Hamano - gitster于2016年4月3日提交3b8c4b7)
lockfile: improve error message when lockfile exists
A common mistake leading a user to see this message is to launch "
git commit
", let the editor open (and forget about it), and try again to commit.引导用户查看此消息的一个常见错误是启动“git commit”,让编辑器打开(并忘记它),并再次尝试提交。
The previous message was going too quickly to "a git process crashed" and to the advice "remove the file manually".
前面的消息对于“一个git进程崩溃”和“手动删除文件”的建议太快了。
This patch modifies the message in two ways:
这个补丁通过两种方式修改消息:
- first, it considers that "another process is running" is the norm, not the exception,
- 首先,它认为“另一个进程正在运行”是常态,而不是例外,
- and it explicitly hints the user to look at text editors.
- 它明确提示用户查看文本编辑器。
The message is 2 lines longer, but this is not a problem since experienced users do not see the message often.
消息是2行更长,但这不是问题,因为有经验的用户不经常看到消息。
#4
0
mine was solved with both answers from Platinum Azure then Suhail Taj
我的这两种答案都是用白金,然后是Suhail Taj。
git commit -am "Changed this, that, and the other thing"
Then
然后
$ rm -rf .git/index.lock
#1
11
Assuming you're not doing anything with git at the moment (i.e., not doing a push or pull or running a git script in the repository, for any reason), you could just remove the lock file manually and try again.
假设你现在没有在git中做任何事情(例如:因为任何原因,您都可以手动删除锁文件,然后再试一次。
Also, git expects a "commit message" describing your changes. Assuming you don't want an editor to open, you can provide an inline message using the -m
option:
另外,git希望“提交消息”描述您的更改。假设您不希望编辑器打开,可以使用-m选项提供内联消息:
git commit -am "Changed this, that, and the other thing"
#2
12
Removing index.lock file manually from .git directory worked.
删除索引。手动从.git目录手动锁定文件。
or
或
From command line:
从命令行:
$ rm -rf .git/index.lock
Note: Make sure that only one index file exist on .git directory
注意:确保在.git目录中只存在一个索引文件。
#3
1
Note the message will improve and be more explicit with git 2.9 (June 2016), in order to invite you to consider all the causes before removing that lock yourself.
请注意,该消息将会得到改善,并在git 2.9(2016年6月)中更加明确,以便在删除锁之前邀请您考虑所有原因。
See commit aed7480, commit 3030c29 (01 Mar 2016) by Matthieu Moy (moy
).
Helped-by: Moritz Neeb (zormit
).
(Merged by Junio C Hamano -- gitster
-- in commit 3b8c4b7, 03 Apr 2016)
见提交aed7480,由Matthieu Moy (Moy)提交3030c29(2016年3月01日)。得益于:莫里茨Neeb(zormit)。(由Junio C . Hamano - gitster于2016年4月3日提交3b8c4b7)
lockfile: improve error message when lockfile exists
A common mistake leading a user to see this message is to launch "
git commit
", let the editor open (and forget about it), and try again to commit.引导用户查看此消息的一个常见错误是启动“git commit”,让编辑器打开(并忘记它),并再次尝试提交。
The previous message was going too quickly to "a git process crashed" and to the advice "remove the file manually".
前面的消息对于“一个git进程崩溃”和“手动删除文件”的建议太快了。
This patch modifies the message in two ways:
这个补丁通过两种方式修改消息:
- first, it considers that "another process is running" is the norm, not the exception,
- 首先,它认为“另一个进程正在运行”是常态,而不是例外,
- and it explicitly hints the user to look at text editors.
- 它明确提示用户查看文本编辑器。
The message is 2 lines longer, but this is not a problem since experienced users do not see the message often.
消息是2行更长,但这不是问题,因为有经验的用户不经常看到消息。
#4
0
mine was solved with both answers from Platinum Azure then Suhail Taj
我的这两种答案都是用白金,然后是Suhail Taj。
git commit -am "Changed this, that, and the other thing"
Then
然后
$ rm -rf .git/index.lock