Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists

I am still getting this error message, when I try to move my project tree on to git repo.

I checked the permissions of my directory with this project and these are set on 777. In terminal in the directory with my_project I set:

git init

and then if I try

git add .

or

git commit -m "first upload"

so I'll get the error

fatal: Unable to create '/path/my_proj/.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.

I tried also create a new repo and there to commit it, but unfortunately still the same error message.

What is the cause of problem?

question from:https://stackoverflow.com/questions/66047789/why-am-i-facing-this-error-everytime-i-try-to-commit-my-work-to-a-repo-on-githu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try

rm -f ./.git/index.lock

In your repository directory. The error message is rather explicit as to what causes it typically, so if you have no other git processes running (which is the normal case), go ahead and delete that file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...