How to change the project owner in GitLab

Gitlab

Gitlab Problem Overview


How can I change the project owner in GitLab?

There are options in project settings, but in the "transfer" field, it does not recognize any username or anything. Is it possible to change the owner-permissions and root-privileges?

Gitlab Solutions


Solution 1 - Gitlab

TL;DR

Move your project to a new group where both you and the other user are owners, then the other user must transfer it to his own namespace.

Background

The other answers obviously do not work to transfer a project to a different user, although the comments section of one is enough for someone to figure it out. Also there is this issue on GitLab itself that provides some insights.

My Situation

I installed and now administer a few instances of GitLab for a few small developer teams as well as one for my personal projects. Resultingly, I have run into numerous questions about this. I keep coming back to this question only to realize that it was never actually answered correctly.

The Namespace Problem

The issue that you face when doing this is that there can only be one owner of a project, but to transfer a project you have to own the namespace that you are transferring it to. To my knowledge there is no other way to move a project. For completeness, I'll add that the namespace here is, e.g., "gitlab.com/my-user-name/..." or "gitlab.com/my-group-name/...".


Solution

Because one user cannot "own" another namespace (not even admins), the only option to set up a scenario where two users own the same namespace is with a group. Perform the following steps to accomplish this.

  1. Create a new group.
  2. Add the user that you want to transfer your project to as an owner member of that group.
  3. Transfer your project to that group (a namespace you manage because you are an owner).
  4. Login as the other user, then transfer the group project to the "other user" namespace.

At this point you will be left as a master in the project. You can now remove yourself from the project entirely if desired.

Solution 2 - Gitlab

You can add another owner to the project via:

Project -> Members -> Add members -> Select Owner as permission

Next you have to remove yourself from the project:

Project -> Members -> Click the red button behind your username

Now you left the project, and the user you entered before is now the owner.

Solution 3 - Gitlab

You can basically create a group then add the project to a group, then from the group member setting add a new owner and you can leave the group yourself.

See screenshots

enter image description here

Solution 4 - Gitlab

It is also possible to export the project and import it under a different user. This preserves commits and branches.

Settings -> Advanced -> Export Project

Then to import:

New Project -> Import Project -> Gitlab Export

Solution 5 - Gitlab

If you need to do this for many projects, it's pretty convenient to do it via API:

import gitlab
gl = gitlab.Gitlab('https://gitlab.com', private_token='...')

gitlab_project = gl.projects.get("the-project-of-yours")
target_group = gl.groups.get("target-group-where-to-land")
gitlab_project.transfer_project(target_group.id)

https://docs.gitlab.com/ee/api/projects.html#transfer-a-project-to-a-new-namespace

https://docs.gitlab.com/ee/api/groups.html#transfer-project-to-group

https://github.com/python-gitlab/python-gitlab/blob/master/gitlab/v4/objects/projects.py#L461

Solution 6 - Gitlab

It involves multiple steps, but its possible.

  1. Create a group and transfer project to the group
  2. Invite new user to the group
  3. Login with new user and transfer project to new user from group
However I think it is easier to maintain if you leave your repository in the group

Transfer menu are always at Project => Settings => Advanced

Solution 7 - Gitlab

In Gitlab 8.8.3 you are able to transfer a project. Be careful. Changing the project's namespace can have unintended side effects ;)

Go to Project -> Settings -> Project Settings -> Scroll down to Transfer project

Change project namespace in Gitlab

Solution 8 - Gitlab

In current version (10.2.4) you should do following:

Go to "Project" -> "Settings" -> Expand "Advanced settings" -> Scroll down to "Transfer project"

Solution 9 - Gitlab

In GitLab Community Edition 9.3.5 if you are administrator you should go to Settings -> Members and change de role of the member you want.

For example, search John Doe, set the developer role, and now John Doe will be developer and won't be owner anymore.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCharmaView Question on Stackoverflow
Solution 1 - GitlabJakeDView Answer on Stackoverflow
Solution 2 - GitlabjvanbaarsenView Answer on Stackoverflow
Solution 3 - GitlabpitasideView Answer on Stackoverflow
Solution 4 - Gitlabuser2789873View Answer on Stackoverflow
Solution 5 - GitlabTomas TomecekView Answer on Stackoverflow
Solution 6 - Gitlabuser918475View Answer on Stackoverflow
Solution 7 - GitlabmatzeihnseinView Answer on Stackoverflow
Solution 8 - GitlabDavit YavryanView Answer on Stackoverflow
Solution 9 - GitlabSebastianView Answer on Stackoverflow