7

I have created several repositories in GitLab.Now I want to rename or remove repository. How can I do this? is there any API available? or is there any git command available for this?

Harsh Patel
  • 6,334
  • 10
  • 40
  • 73

4 Answers4

11

To rename a repository on GitLab:

  1. Navigate to your project's Settings > General > Advanced settings.
  2. Under "Rename repository", change the "Path" to your liking.
  3. Hit Rename project.
midi
  • 3,128
  • 5
  • 30
  • 47
  • 4
    There is no "Rename repository" at at 2022-03-26, but there is a "Change path". When I changed this, it seemed to work but the project, on the "Projects" page, is still the old name. Then I found you can change the name at the TOP of the "Advanced" page. – mike rodent Mar 26 '22 at 14:49
2

I guess by repository you mean projects. If you just want remove them from the GUI have a look at this issue. If you have the latest version of GitLab have a look at the second answer also cause it seems there are some changes made recently.

If you want to rename the projects through the API you can have a look at the documentation. Have in mind that to use the API you have to make sure it is enabled and also if it is self-hosted, that you are using the correct path when making the requests

dstrants
  • 7,423
  • 2
  • 19
  • 27
1

SEEMINGLY NOT POSSIBLE

Try this: your project --> Settings (gearwheel icon) --> General --> Advanced

There is no "Rename repository" as at 2022-03-26, but there is a "Change path". First change this.

At the top of the "Advanced" page you also have to change the "Project name" and then click "Save changes".

This seems to have changed everything. However, it is not so!

If you then try to git clone from a Terminal using the old name, the old project will indeed be cloned. Equally, if you try to push an initial commit of a new project, this will be rejected. Annoyingly therefore, it appears that Gitlab doesn't implement this properly.

WORKAROUND

Very simple: remove the project COMPLETELY from Gitlab. Then recreate it using your chosen method under a new name.

mike rodent
  • 14,126
  • 11
  • 103
  • 157
0

Mike Rodent wrote:

WORKAROUND

Very simple: remove the project COMPLETELY from Gitlab. Then recreate it using > your chosen method under a new name.

Easier said than done! I had to create a new repo in gitlab, and I noticed there was in the relevant subgroup an existing project. This project's name happened to begin with "S", and seeing the button with an "S" in it, I assumed "S" stood for subgroup and that I would thus have to create a subgroup for my repo (instead of a project).

On finding out that there was apparently no way to create a repo directly in a subgroup, and realising from other examples that the letter in the button was simply the first letter of the name, I then had to delete the subgroup in order to create a new project instead. But the wretched thing insists on keeping the deleted subgroup around for a week, despite the fact that it is empty and I want it gone NOW, and I can't create the project with the same slug name because it says that name already exists (as part of the now zombified subgroup I tried to delete).

So in summary:

  1. If you want to remove a project COMPLETELY from Gitlab, it may take you a week, until it deigns to actually delete it!

  2. Why the hell does the first letter of a subgroup name or project name appear in the button to the left of it? What does this gain? It is redundant and just confusing (as I found)

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 30 '23 at 21:43