[go: up one dir, main page]

Skip to content

Restoring a backup fails if there is a branch called HEAD

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

We have a self hosted gitlab server.

A year ago, someone accidentally (and I really don't know how) pushed a branch called "HEAD" to one of our repos. This has just been sitting there with no problems on the server.

But now we moved to a new server and all seemed to work. Except when someone cloned this specific repo, he got an error message saying something about a wrong ref. And then we found out that in the gitlab webview, it looked like the files were all from a different repo in the same group. The fix was to go back to the original server, delete the HEAD branch, backup this repo and restore it. It's possible that some git magic could have fixed it as well, but this worked for us.

In this case we were saved by having access to the old server, as it was just an upgrade. If it had blown up, then we could have lost some of that repo - maybe not, depends on what the fix would then have been.

This clearly isn't gitlabs fault. It's IMHO a git bug that it's even possible to create a branch called HEAD. But that said, gitlab could have made us aware of the problem.

My suggestion: Make a check on each repo for a list of known bad names - HEAD is definitely in this list. I would prefer that the backup fails, or at least writes an error message after it's done, if one of these bad branch names exist. That would have solved the problem immediately, as we would have detected the problem and removed that branch.

Edited by 🤖 GitLab Bot 🤖