threads / discuss / 37332

Error "fatal: not a git repository" after auto packing

Subject: Error "fatal: not a git repository" after auto packing

## tl;dr

4 messages between Aug 11, 2014 and Aug 12, 2014.

replies: 3people: 3as markdown or json

Luke Campagnola· Aug 11, 2014, 22:56 UTC · lore
Greetings,

I have been working happily with git for a couple of years, and ran into a mysterious issue today: after running a git-pull during which I saw the message "Auto packing the repository for optimum performance". I now receive the error "Fatal: not a git repository" when running any git commands, and a little investigation revealed that my .git/refs directory has gone missing, presumably because the refs were all combined into .git/packed-refs. To restore access to the repository, all I needed was to `mkdir .git/refs`. Is this a known bug? It seems like either git should tolerate the absence of a .git/refs directory, or the auto packer should not remove it.

I am using git 1.9.1 on kubuntu 14.04. The surrounding console output follows:
raven:/home/luke/vispy (transform-cache)$ git commit -a
[transform-cache 15a0fe3] Optimizations for grid_large
 6 files changed, 91 insertions(+), 52 deletions(-)
raven:/home/luke/vispy (transform-cache)$ git push lcampagn transform-cache
Counting objects: 114, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (31/31), 4.00 KiB | 0 bytes/s, done.
Total 31 (delta 25), reused 0 (delta 0)
To git@github.com:lcampagn/vispy.git
   24b37a6..15a0fe3  transform-cache -> transform-cache
raven:/home/luke/vispy (transform-cache)$ git fetch vispy
remote: Counting objects: 78, done.
remote: Compressing objects: 100% (78/78), done.
remote: Total 78 (delta 34), reused 0 (delta 0)
Unpacking objects: 100% (78/78), done.
From https://github.com/vispy/vispy
   ec740af..fd8aa37  master     -> vispy/master
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 5349, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5315/5315), done.
Writing objects: 100% (5349/5349), done.
Total 5349 (delta 3977), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.

raven:/home/luke/vispy (transform-cache)$ git checkout master Switched to branch 'master' Deleted 103 .pyc files Deleted 11 empty directories

raven:/home/luke/vispy$ git pull vispy master fatal: Not a git repository (or any of the parent directories): .git

raven:/home/luke/vispy$ git status fatal: Not a git repository (or any of the parent directories): .git

raven:/home/luke/vispy$ ls -al .git total 288 drwxr-xr-x 6 luke luke 4096 Aug 11 17:09 . drwxr-xr-x 9 luke luke 4096 Aug 11 09:25 .. -rw-r--r-- 1 luke luke 601 Aug 11 12:22 COMMIT_EDITMSG -rw-rw-r-- 1 luke luke 1088 Aug 11 09:21 config -rw-r--r-- 1 luke luke 73 Mar 2 08:41 description -rw-r--r-- 1 luke luke 323 Aug 11 16:56 FETCH_HEAD -rw-r--r-- 1 luke luke 337 Mar 3 10:18 GIT_COLA_MSG -rw-r--r-- 1 luke luke 193478 Aug 11 11:14 gitk.cache -rw-rw-r-- 1 luke luke 23 Aug 11 17:09 HEAD drwxr-xr-x 2 luke luke 4096 Mar 8 07:30 hooks -rw-rw-r-- 1 luke luke 31104 Aug 11 17:09 index drwxr-xr-x 2 luke luke 4096 Aug 11 16:57 info drwxr-xr-x 3 luke luke 4096 Aug 11 16:56 logs drwxr-xr-x 105 luke luke 4096 Aug 11 16:57 objects -rw-rw-r-- 1 luke luke 41 Aug 11 09:25 ORIG_HEAD -rw-rw-r-- 1 luke luke 8210 Aug 11 16:56 packed-refs

Duy Nguyen· Aug 12, 2014, 15:41 UTC · re: Luke Campagnola · lore

Re: Error "fatal: not a git repository" after auto packing

On Tue, Aug 12, 2014 at 5:56 AM, Luke Campagnola <luke.campagnola@gmail.com> wrote:

Show 10 quoted lines
> Greetings,
>
> I have been working happily with git for a couple of years, and ran
> into a mysterious issue today: after running a git-pull during which I
> saw the message "Auto packing the repository for optimum performance".
> I now receive the error "Fatal: not a git repository" when running any
> git commands, and a little investigation revealed that my .git/refs
> directory has gone missing, presumably because the refs were all
> combined into .git/packed-refs. To restore access to the repository,
> all I needed was to `mkdir .git/refs`. Is this a known bug?
Not to me.
> It seems
> like either git should tolerate the absence of a .git/refs directory,
> or the auto packer should not remove it.

I tried to clone from vispy.git, running 'git gc' manually and 'pack-refs' (which should be in charge of removing empty dirs with v1.9.1. Things worked fine. Looked at refs.c:try_remove_empty_parents() as well. Still could not find any bug there.. So no good news. I don't suppose that if you run "git gc" again, it would remove $GIT_DIR/refs one more time?

-- 
Duy
Dennis Kaarsemaker· Aug 12, 2014, 16:11 UTC · re: Luke Campagnola · lore

Re: Error "fatal: not a git repository" after auto packing

On ma, 2014-08-11 at 18:56 -0400, Luke Campagnola wrote:
Show 5 quoted lines
> 
> raven:/home/luke/vispy (transform-cache)$ git checkout master
> Switched to branch 'master'
> Deleted 103 .pyc files
> Deleted 11 empty directories

This looks like you have a local post-checkout hook that deletes empty directories. Fix that hook to not do anything in .git and it should be fine.

-- 
Dennis Kaarsemaker
www.kaarsemaker.net
Luke Campagnola· Aug 12, 2014, 16:16 UTC · re: Dennis Kaarsemaker · lore

Re: Error "fatal: not a git repository" after auto packing

On Tue, Aug 12, 2014 at 12:11 PM, Dennis Kaarsemaker <dennis@kaarsemaker.net> wrote:

Show 10 quoted lines
> On ma, 2014-08-11 at 18:56 -0400, Luke Campagnola wrote:
>>
>> raven:/home/luke/vispy (transform-cache)$ git checkout master
>> Switched to branch 'master'
>> Deleted 103 .pyc files
>> Deleted 11 empty directories
>
> This looks like you have a local post-checkout hook that deletes empty
> directories. Fix that hook to not do anything in .git and it should be
> fine.
Of course you are correct. Sorry for the noise.

← back to recent threads