Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 'Updating the Git index failed' displayed

I am using Windows. When staging files I get this error.

Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui.

followed by a list of files which have been converted from LF to CRLF

After a lot of reading up on the CRLF / LF issue with Git usage cross platform, I more or less understand what is going on, and I am trying to determine which autocrlf setting is best for me, but I cant understand why Git says that Updating the index failed. My understanding is that it has converted the EOF's so what is the problem with that and why is it telling me that updating the index has failed. Do I need to fix something ( other than picking an appropriate autocrlf setting) or can I just proceed

I then have two options Continue and Unlock Index, what do these mean and what is the best course of action.

like image 823
byronyasgur Avatar asked May 13 '12 17:05

byronyasgur


People also ask

What is Unlock index in git GUI?

What does "Unlock Index" do in the Git Gui? It removes the ". git/index. lock" file so that you can run other git commands before continuing. The Git GUI will create this file when it starts a Git command so that no other git processes will interfere and corrupt your local repository.

What is the git index?

The Git index is a critical data structure in Git. It serves as the “staging area” between the files you have on your filesystem and your commit history. When you run git add , the files from your working directory are hashed and stored as objects in the index, leading them to be “staged changes”.

What is refresh index in git?

git/index changed by windows. So it can only refresh the index and replace the . git/index file, which makes the next git status super fast and git status in windows very slow (because the windows system will refresh the index file again).


1 Answers

git config --global core.autocrlf false 

Has always been my recommendation (see "Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination").

However, in your case, you can "Continue", but this warning is there to mention the conversion of certain files might not be reversible:

core.safecrlf 

If true, makes git check if converting CRLF is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly. For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of core.autocrlf, git will reject the file.
The variable can be set to "warn", in which case git will only warn about an irreversible conversion but continue the operation.

If you don't want to see this warning, as explained in this thread, you can set core.safecrlf to false.

You could also stash your files through the tools menu of git gui, and add some options to those tools with, for instance, this git config file.
The interest is that, for each tool, you can add:

guitool.<name>.norescan 

Don’t rescan the working directory for changes after the tool finishes execution.


Could you please elaborate a bit on Unlock Index

you can see that message in the index.tcl git-gui script: it removes the index.lock file the git-gui creates when manipulating the index.
You can see more at the "lockfile API" documentation page:

Mutual exclusion.
When we write out a new index file, first we create a new file $GIT_DIR/index.lock, write the new contents into it, and rename it to the final destination $GIT_DIR/index.
We try to create the $GIT_DIR/index.lock file with O_EXCL so that we can notice and fail when somebody else is already trying to update the index file.

like image 68
VonC Avatar answered Oct 17 '22 07:10

VonC