How to Delete a Repository

Replace this template with your information

Hello,

I have searched in your docs, and done a general Google search, but I can’t find a way to delete a repository. I found out how to delete a project, but not a repository in the project. I’m the owner of the project and repository, and I want to remove the repository. I found a result for using the API to do it, but is there no way to do so on the web?

I’d rather not have to delete the whole project, but if I have to to get rid of the one repo, I will.

Thanks
Describe your question in as much detail as possible:

  • What are you seeing, and how does it differ from what you expect to see?
  • Consider including screenshots, error messages, and/or other helpful visuals
  • What version are you on (Hint: /help) ? and are you using self-managed or gitlab.com?
  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

Thanks for taking the time to be thorough in your request, it really helps! :blush:

Hi @blackfeather ,

Before do a comment, I would like to ask you 3 questions, maybe there are silly but I think they are important to be on the same page.

According to you:

  1. What is a GitLab project?
  2. What is a GitLab repository?
  3. What function/method/endpoint of the API did you use to remove/delete the repository?

For the information that I know, a repo can not be removed or deleted from a project.

Waiting for your comments.

Best Regards,
JB

  1. From https://docs.gitlab.com/ee/user/project/index.html:
    “In GitLab, you can create projects to host your codebase. You can also use projects to track issues, plan work, collaborate on code, and continuously build, test, and use built-in CI/CD to deploy your app.”

Basically, it’s a way to organize one’s work.

  1. A GitLab repository is a place to keep one’s code, assets (e.g., images, videos, binary data etc), version it (via the git protocol/standard), and allow for collaboration (via cloning, pushes, merges, cherry-picks, etc.).

From https://git-scm.com/ (the homepage for git)
“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.”

Git has become over the last decade the major standard for code collaboration in the open source community (and many close-sourced communities as well, but such data is inherently less easy to obtain).

  1. I didn’t, that’s the whole point of my asking. I can see that in some cases, removing a repo could cause inconsistencies with other parts of the project. It won’t in my case as the project only has the repo in it, and nothing else. But if a user is willing to accept that, they should be able to delete their own repo.

If there’s a way to delete it via API, I suppose I could do that, but it’s hardly worth the effort in this case (it might be in other cases).

I think the reason @jboada was asking is that it’s unusual to remove an existing repository, especially if you have already pushed commits to it.

I think you probably want to go to Settings → General → Visibility, project features, permissions in your project, and make your repository invisible. That way you can still use the project for issues, etc. I have a few projects configured like this, primarily where I only want to use one project feature (usually the issues board or wiki).

However, this does not delete the repository, it just hides it. You can make it visible again if you ever wish to.

HTH

Hi @blackfeather and @snim2 ,

I hope both of you are doing good.

@blackfeather about the points 1 and 2, we are on the same page.

Maybe I did not understand your question when I read it (I was really tired, I apologize for it).

On one hand, my answer to your question is, No, there is no way as far as I know. Delete the repository of a project could mean delete the whole project.

On the other hand, deleting/removing a repository from a project is like that you only wanted one or more features of a GitLab project like @snim2 mentioned. The best approach I can think right now for this scenario would be a project with no files added to it, not even the readme file to initialize the repo, it is project with no repository in it.

Best Regards,

JB

1 Like