7

I tried to soft reset my branch to remove a directory I had accidentally pushed to GitHub. After the soft reset I was still getting the following error:

fatal: Unable to create '/Users/mprestemon/vagrant-local/www/national-fuel/public_html/wp-content/.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 came across another StackOverflow article that said to remove .git/index.lock with the following command:

rm -f ./.git/index.lock

When I run that command and try to checkout or pull from another branch I now get this BUG:

BUG: unpack-trees.c:699: pos must point at the first entry in this directory

I can't figure out how to clean up my repository and ensure that all git processes have been completed/aborted. Any advice how to get around this?

  • 2
    The Git list is probably interested in your hitting this bug and might be able to offer tips. – bk2204 Aug 13 '20 at 00:53

5 Answers5

8

I ran into this same error. When I tried git reset --hard HEAD I got the message about the index.lock file. So, I manually deleted the file, tried the hard reset again, and then got the BUG: unpack-trees.c etc etc....

What wound up working for me - since I didn't care about losing any changes that had been made - was checking with git status to see what all had been altered, and then using git restore --staged . to simply remove everything being watched by git.

After that, I was able to check out the branch I was trying to switch to without any trouble.

Terminal workflow screenshot

Texian
  • 91
  • 1
  • 6
3

I accidentally managed to stage all source files for deletion in my source tree and afterwards ran into the same bug.

I could not do a reset or checkout, but finally was able to restore everything via

git restore .

and afterwards could use git normally again.

Maybe this helps...

Oliver F.
  • 86
  • 4
0

I don't have an answer, but ran into this same issue simply trying to update my local branch. There was nothing weird going on, my local branch was clean, just a routine update from origin:

(base) camalot:Fellowship andrew$ git pull origin master
From https://github.com/andrew-gerlach/Fellowship
 * branch            master     -> FETCH_HEAD
Updating 4a8ffa3..e48acaa
BUG: unpack-trees.c:699: pos must point at the first entry in this directory
error: merge died of signal 6

The git restore --staged . worked for me but didn't work without the --staged flag

0

I had the same issue on a Windows PC, and running:

git config core.protectNTFS false

per wdtj's answer to this question resolved the matter.

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
0

I have a similar problem, but git restore --staged <filename> doesn't do anything at all. All the staged files are left still staged and still show up in git status. Interestingly, all the staged files are in my doc subdirectory, but the unpack error seems to relate to my PCB subdirectory: BUG: unpack-trees.c:774: pos 25 doesn't point to the first entry of PCB/ in index

This is on a M1 Mac, so I doubted the Windows NTFS thing would help, but I tried it anyway. Something changed, as 2 new files in the PCB directory now show up under git status that were not listed before, and the unpack-trees error went away.

Some of the untracked files in the PCB directory have a '#' in the filename, but the 2 tracked files do not. I don't have control over those filenames, as they are automatically generated by Eagle CAD. None of them contain a ':'.

Removing the index.lock file just gets me error: You have not concluded your merge (MERGE_HEAD exists).