Skip to content

Git: Not a valid object name HEAD on loading repository #942

@fdavies93

Description

@fdavies93

Problem

When gitlist tries to load a repository where the HEAD is set to a non-existent branch, which can happen in backup situations, it will fail and return a 500 error with the log message git: fatal: Not a valid object name HEAD.

I found this is particularly a problem when self-hosting bare git repositories, since the location of HEAD is non-obvious in this case.

Workaround

Enter the broken repository and set HEAD to a branch that actually exists:

git symbolic-ref HEAD refs/heads/main

Proposed Solution

Instead of failing to load, gitlist should search for plausible main branches such as master, main, or trunk. If it does not find these, it should select the first branch that it finds as the default branch to render.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions