Error: Another git process seems to be running in this Repository

Asked

Viewed 9,952 times

10

I have a repository with several files, including html, javascript, css among others, and today I had this error, I’ve researched quite a lot more no solutions so far surtiu effect.

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.

  • If it doesn’t work out delete the lock and rebut the machine and try again should drop. I can’t explain why but the cause is this.

  • @Marcelo, if any of the answers helped you understand the problem don’t forget to mark it as right, so help others with the same question to find the answer more easily.

  • @Marcelo, I don’t understand why in the last few minutes you took the answer as correct, just to avoid receiving the reward? you know that after you put a reward on a survey, even if you don’t give it to anyone as the correct answer it doesn’t come back to you right?

4 answers

16


This error happens because inside the directory .git there is a file called index.lock, after deleting this file you will be able to run git commands.

But after all, what is index.lock.?

The index.lock file is created every time a change occurs in the original index file.
To ensure that the original file doesn’t end up corrupted, git creates index.lock with all the new information, saves and renames it to index, then overwrites the original.

The index file in turn is a binary file (usually maintained in . git / index) containing an ordered list of all paths of files being versioned by git, each with permissions and the SHA1 of the blob of this file.

That is, all files being monitored by git are listed in the index along with their path, permissions (read, write, executable) and SHA1 hash.

You can see the contents of the index file with the command git ls-files.
To display the contents of the index for all the versioned files run:

$ git ls-files -s
100644 d1bed128fa83b3ed094d8387f4b8f19c019e2ae8 0       crud/.gitignore
100644 62dff0d03aeddb3cfc3e10ded315193fcf00f4c4 0       crud/app.js
100644 86091205bdb895f94d904c1c1a00457e2a3355f0 0       crud/bin/www
100644 afa3b3b360b58def97f483a7163032abba849fc9 0       crud/db.js
100644 311524c74e19968b8a580c19ed663b4e2e96a34e 0       crud/package-lock.json
100644 da91bb97990abbf27edbd2c93046054e458d0e4e 0       crud/package.json
100644 9453385b9916ce9bc5e88d2f5d8cd8a554223590 0       crud/public/stylesheets/style.css

The first column with the numbers 100644 represents permissions, the second column is the SAH1 hash, the third is the Stage number (this is used to represent merge conflicts) and the fourth column is the path of your file.
For more details on what I commented above a look in this article and on the eBook Git Community Book.

Now that we understand what the index and index.lock files are for, I think it’s easy to see that whenever we commit, merge, we try to solve a Conflict problem or any other command that git needs to recreate the index it will generate this index.lock file and until this command is completed it will not save and replace the original index file, for this reason git won’t let you run another command while index.lock exists, because it understands that there is another command running at that time.

11

Hello I had this problem I used this command and solved:

rm -f .git/index.lock

I hope it helps whoever has this problem too!

  • 2

    His answer is basically the same as Sandro Silva’s, but Sandro Silva’s is concerned to ensure that there is no more git process running (avoiding any possible corruption of the repository). It is also extremely similar to the accepted answer, but without the explanation contained therein of the cause

8

You need to try to delete the index.lock file on your .git directory.

This problem occurs whenever you run two git commands simultaneously, maybe one from the command prompt and one from the IDE.

  • 1

    It’s not an untreated bug: it’s working as it should. How would you otherwise implement it?

  • Thanks for the @jsbueno comment, yes actually if they add the lock and a message is handled, I just removed **it seems to me ...".

4

Try to see if there is a git process running in windows task manager. If there is, kill the process and delete index.lock in the . git folder

Usually solves the problem ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.