Best way to run git commands on git-data

Hello everyone,

On our local instance of GitLab (11.10.8 on Linux) we are running into an issue with a corrupt git repository. The error messages match exactly the ones described by an issue on corrupt repositories ( A temporary loss of connection seems to have caused invalid references.

fatal: loose object 9a34deed21ae403276a6949ed4379c254cb7eeb4 (stored in ./objects/9a/34deed21ae403276a6949ed4379c254cb7eeb4) is corrupt

We started following the instructions mentioned in one of the comments (, but run into issues with item #3.

  1. Remove empty files with find ./objects/ -size 0 -exec rm -f {} \;
  2. Run git fsck to see which refs now had invalid pointers
  3. Remove the bad refs with git update-refs -d refs/heads/bad-refs
  4. Run git fsck --full .

Item #1 we directly executed on the OS and item #2 on the Rails console.

Now we’re wondering how to best execute item #3 because the command is not available on the Rails console. Should we directly access the folder and execute the command there, or is there a better way to do this?

I searched for an answer on the GitLab repository and here in the forum, but I couldn’t find any helpful information. Before I mess anything up I was wondering if someone can help me with this.

Thank you,