How do I delete absolutely all commits from a repository?

I would like to remove absolutely all commits and all branches from a git repo hosted on an internal Gitlab CE 11.0.3 server. In other words, I want it to be like a newly created project. I don’t want to remove issues and wiki though, so I can’t just delete and recreate the project.

This is in order to test a script that does “mirror” pushes to the repository, specifically to make sure it works when the project exists but is empty.

What I’ve tried:

  • Deleting all branches via the web UI - the button to delete master is disabled.
  • Deleting master from a checkout with git push -f origin :master - Gitlab says The default branch of a project cannot be deleted.
  • Creating an empty orphan commit and pushing that - git fails with src refspec master does not match any
  • Getting the sysadmin to delete the projectname.git folder - just results in a 404 when visiting the project page

So I’m at a loss. I just can’t seem to get the repo back to the “pristine” state it typically is immediately after creation. Is there a way to do this?

1 Like