How can I delete a repository and push a new one?

We’re experimenting with converting our repository from bzr to git. We pushed a repo to our gitlab project, but now we just want to blow that repo away and push a new one, that was converted with higher fidelity. How can we do that?

Hey @barry, you can do this under the project’s settings page on the left sidebar. Once you’re in, scroll to the very bottom and hit Remove project. Once you enter the confirmation, the repo and its data will be nuked.

Thanks @axil. Sorry, I should have mentioned, we’d like to not delete the entire project, just the repo. Is that possible? We don’t have a lot of other artifacts, so if we have to delete the project and recreate it under the same name, we’ll do that. I just want to be sure we’ll be able to recreate it again under the same name. (We’ll have to at least upload our logo again, but I can live with that).

Ah ok, that entails some manual work. Go to /var/opt/gitlab/git-data/repositories/<username> and remove the git repo for this project. After you visit the repo again, you’ll see that it says No repository and you’ll be able to push whatever you want. The logo image will not be lost :wink:

Thanks! We’re using gitlab.com so I guess I need to submit a support request. I’m guessing we don’t have shell access to gitlab.com :smile:

lol yeah submit an issue at https://gitlab.com/gitlab-com/support-forum/issues

1 Like

@barry
Another alternative is to simply delete all the branches and then push your new branches to the server. In my experience that also rids you of all old commits and just gives you the history of the current set of branches you push.

delete master branch
push new master branch

You’ll have to force the delete probably but this should accomplish what you want, I think.

1 Like

It doesn’t seem this functionality is fixed. I can’t find how to delete only the repository and not the entire project.

I can delete branches but I can’t delete the master (screenshot). It’s not in the list of protected branches so not able to remove the protection.

I don’t want to remove the entire project because I’ll lose all the issues/labels created.

How can this be done or fixed?

@ams Did you see @axil’s response here?

it’s 2018 already, is there a way to do this?

lol, nevermind. Just unprotect master then execute git push -f master origin

So I just performed the action suggested by @axil and supported by staff member @markglenfletcher

Now I can’t access the project at all. It just gives a 404 error. Sigh…

Edit : I created another empty project (only readme for repo), copied it over with the same name as the one I deleted. Modified the config file with the new name and set the permissions/owners. This resolved the issue for me.

Did anyone ever figure out how to do this?

I just deleted a repo with the same intention as mentioned by the issuer of this thread. While I was about the delete the specified folders mentioned by @axil gitlab did it itself. It seems, it has been integrated into gitlab. We’re running gitlab CE 12.3.0.

I also deleted (renamed) the repository folder and this lead to a 404. I ended up doing the following:

  1. Restore the repository folder
  2. Unprotect all branches in gitlab
  3. Delete all branches except master from the gitlab UI (I didn’t have many branches)
  4. From my remote: git push -u origin --all
    and git push -u origin --tags

For me, it was even simpler. Here a recipe for the simple case if you only have one branch, main:

  1. In GitLab, unprotect the main branch.
  2. Initialize a new local repo and set its origin to the project’s URL.
  3. Force-push the local repo to GitLab: git push -u -f origin --all.

The old repo should now be replaced with the new repo.