71

Just started out using self hosted GitLab... it looks like it's going to be really useful moving towards a DevOps workflow.

Anyway, after migrating about 20 local Git repositories to the new GitLab server, neatly arranged into 4 groups. I then noticed you can actually have sub-groups within the groups. This would help organisation even further, but I'm struggling to work out how to move the existing projects I've spent a day importing and configuring into a newly created sub-group. Sure I could just create a new project and copy the files over and commit them into the new project, and spend the time reconfiguring the project.

Is there an easy way of moving the existing configured Project from the group into the new subgroup?

Jonas
  • 121,568
  • 97
  • 310
  • 388
James McCorrie
  • 2,283
  • 3
  • 18
  • 22

2 Answers2

125

Turns out the "slug" for a project... the part of the URL after the GitLab server domain name is made up of the "namespace" and the project name. The name space is the group/subgroup path, so I was looking to transfer project to new namespace.

So for example if the group is "important-group" and project is called "project". Then the slug will be something like /important-group/project. To then move that to /important-group/sub-group/project, we need to create the new subgroup (down arrow next to the "New project" button). Then change the project namespace.

To do this, go to the project page, click the settings button (cog bottom left). Go to the Advanced settings section. And it's just below the rename project option.

note: you need to have "owner" privileges on the project otherwise the settings don't appear... maintainer or developer is not enough.

Transfer project to new Namespace

Just select the new subgroup and your done!

Here is the GitLab docs link with more info on managing projects in GitLab, in case that is useful to anyone.

James McCorrie
  • 2,283
  • 3
  • 18
  • 22
  • At the moment I've made a few moves and emotionally stumbled over the point *`Be careful. Changing the project's namespace can have unintended side effects.`* Apart from the well-documented aspects, are there any things you should definitely watch out for? For example, is there any kind of data loss to be afraid of? – Wolf Jan 05 '23 at 14:48
  • 1
    There shouldn't be any data loss, worst case is you transfer it back to where it came from and everything should still all line up again. If you change the project URL then any existing git checkouts will need their origin updating with the new URL `git remote get-url origin` to see where a repo's origin is pointed to and `git remote set-url origin ` to update it. Also if you have any reporting/scripts/pipelines that have the URL hard coded then they will need updating. Hope that helps :) – James McCorrie Jan 06 '23 at 13:46
5

One note:
To use @James McCorrie instruction, one needs to be the "owner" of the project. "Transfer Project" section is not visible for the maintainer, developer, etc. roles.

afar
  • 135
  • 2
  • 6
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33801185) – Edward Feb 14 '23 at 21:51
  • Thanks that is a good point. I've added this information to my answer so it's more obvious to people reading this. – James McCorrie Feb 18 '23 at 17:22