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

Viewed 1600

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?

5 Answers

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

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...

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

I ended up deleting everything locally and cloning the repo again. That seemed to do the trick!

Related