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


#1

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?


#2

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.


#3

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).


#4

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:


#5

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:


#6

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


#7

@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.


#8

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?


#9

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


#10

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


#11

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


#12

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.