可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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:
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.
Is there any way for me to fix this or should I just start a new repository?
回答1:
try deleting index.lock
file in your .git
directory.
Generally such problems occurs when you execute two git commands simultaneously maybe one from command prompt and one from IDE.
回答2:
Try with this:
rm -f ./.git/index.lock
Note: Such problems may occur when you execute two git commands simultaneously maybe one from command prompt and one from IDE. So deleting .lock
file in your .git
directory can work.
回答3:
Use the below command in the root directory of the application. This will delete the index.lock file and release the active lock.
rm .git/index.lock
回答4:
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?
回答5:
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.
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.
回答6:
Removing index.lock file may help you with this. Go to project inside which you have set the origin for git repo. run the following command
rm -f ./.git/index.lock
It has always worked for me.
回答7:
It is similar to above methods but in my case I had several of those
.git/refs/heads/.lock
and was able to remove all at once by this command
find -name "*.lock" | xargs rm
回答8:
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.
回答9:
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.