gitmoji-cli: Unable to create .git/index.lock

Hello @carloscuesta 😎!

Since a while now, every time I commit (I have the pre-commit hook installed), after it, I get this message:

ERROR: fatal: Unable to create '/Projects/pathname/.git/index.lock': File exists.

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.

I’ve tried removing and installing the pre-commit hook, removed gitmoji-cli completely and updated to the most recent version - nothing helps. I encounter the same problem without pre-commit hook and just using the gitmojicommand. When I just commit normally (without gimoji) everything works fine 👌 .

Any ideas?

KR

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 8
  • Comments: 26 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@martinfengshenxiang yeah! That’s true! gitmoji -c whill running git add . & git commit -m '' default. so I run gitmoji -g and choose N to close git add .

image

After that, just fine.

As the error messages says, this problem comes from:

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.

And basically this happens when a git process is killed therefore the lock file is left over.

I’ve been investigating and I haven’t found a solution yet. It’s really weird because it’s hard to reproduce the error. IMHO I think the issue is related with use of the hook option

https://github.com/carloscuesta/gitmoji-cli/blob/ea99b5166c2d642d72be7f536d69127cecb99409/src/gitmoji.js#L108-L113

It really never happened to me, at least with gitmoji-cli. I’ve faced this issue (when cancelling a pull, commit etc.) while using the basic git command and I’ve fixed it by running:

rm -rf .git/index.lock

Any help is appreciated! 👍

I also met the same problem, did you find the solution?

I’am also don’t have the index.lock file. when I am running git add --all & git commit -m ‘add some file’, get the error. But after I running each command seperately, problem solved! I runned: git add --all git commit -m 'add some file' just like magic😊

I’am also don’t have the index.lock file. when I am running git add --all & git commit -m ‘add some file’, get the error. But after I running each command seperately, problem solved! I runned: git add --all git commit -m 'add some file' just like magicblush

I think that’s because it should be git add --all && git commit -m 'add some file' with a double & if you wanna run the cmds separately

@gluons @svenlombaert @Seaony @samirdhebar @LBreda

I’ve created a branch at lab-fix-index-lock @ https://github.com/carloscuesta/gitmoji-cli/commit/ab31066160eadf63c924054d4418847550fc6e8d to test out some fixes, could you please try to install the cli from this branch and see if the problem persists?

$ npm i -g git://github.com/carloscuesta/gitmoji-cli.git#lab-fix-index-lock