Move existing repo to a new owner and make my copy a fork?

I’m trying to move a currently private repo to a new owner where I can make it public and also so that all the repos for the entire system are under the control of one user. Then I want my copy under my username to be a fork of that repo so we can move to a more normal method of integrating changes in an open source project.

Right now it’s a private repo with my username on a free account at gitlab.com. I created a new user also with a free account. I added that user to the repo as an owner. Then I tried to remove me personally as owner which was not allowed. When I try to update the connections from my IDE that allow me to do commits etc I can’t seem to update which user I should be. Both the new owner and the old owner will have their copies on my main computer. I can’t figure out how to tell the various systems that my personal version should be a fork and the canonical copy is the one that will be under the control of a different user and also how to switch between them when I am in “admin mode” ie accepting pull requests from me as a normal user to be applied to the public repo and also accepting them from other contributors or developers.

I have 5 repos I need to do this with.

Typically I’ve been doing development by doing all commits and pushes directly to the repo both locally and on GitLab with no code review or anything. As we move these projects into the open source sphere where I need to allow but also verify contributions from others I decided I need to change the system.

Ideally I’d also like to basically squash the commit history so that it’s a lot cleaner in the new public repo. When I started I didn’t know git at all and I didn’t have any structure for how I did commits and pushes and there are lots of old stale branches and junk that could be cleaned up if I can learn how to do it. I am still a beginner and have been getting lost in the git commands and options.

So far I’m reading the GitPro book to try to learn. I am on a mac running Ventura and I am using 3 tools to manage the source, Android studio for the mobile apps, JetBrains PyCharm for the desktop and web apps and Obsidian for the markdown code that is the database create statements and example queries. For the 2 code systems I use the IDEs to do all the git stuff. For the database I use GitKraken as a tool to handle when I merge, branch and commit to the database repo.

Suggestions on how to do this as well as any other learning sources are most welcome.

1 Like

I would try to use your original owner (OO) to lower its own permissions to something as simple as developer. Then I would take the new owner (NO) and remove OO entirely from the project.

From there, I would delete any local copies (assuming there are no changes to be pushed) and just fork the NO copy to your personal user (OO) again via the gitlab UI. Then clone that fork and off you go.

1 Like

What you want to do is transfer your gitlab project to a new namespace.

Log in as New Owner.
In the project, go to settings > advanced.
There is a setting there to transfer the project. In the select box, select New Owner.
If you want, you can also create a group in gitlab and transfer the project to that, which makes it easier to manage a project with multiple official maintainers.

Both users and groups will be in the select box there.

After transferring the project, every user that is member of the project will receive an email that includes git commands for locally changing the path to the new remote location.

After this, you can log in as Old Owner (OO), go to the now transferred project, and just create a new fork in the OO namespace.

1 Like

Not possible. No options to change OO permissions when logged in as OO.

1 Like

Getting closer. I transferred the repo to the new owner. Actually to a new group that the new owner has. What I’m trying to do now is remove the old owner as an owner. I can’t do anything with my own permissions when I’m logged in as old owner. When I try to do it when logged in as new owner I am not allowed to remove the old owner.

Then I tried to set the old owner to a lower level like developer or even guest and I get an error message “An error occurred while updating the member’s role, please try again.”

Then I tried to set an expiration date for the old owner a few days into the future figuring that would get rid of the old owner eventually but I get an error “An error occurred while updating the member’s expiration date, please try again.”

I’ve tried multiple times, waited a day and tried again and still all the same errors and issues.

My goal is to completely eliminate the old owner from the repo. The new owner will be the only one who has the full control of the repo.

Then as old owner then I’ll go back and fork the repo so I can do my development as if I am a normal outside developer/user.

I’m still stuck on how to do this.

Replying to myself. I finally gave up and realized I was spending more time trying to make it work than I was getting the job done. So the final procedure is this:

  1. Create a new empty repo except for the readme in the new user account.
  2. Log in the old user account and go to the new empty repo and fork it.
  3. Clone the fork down to my computer as the old user.
  4. In the IDE of the project (in my case either PyCharm or Android Studio) open up the old project and the new empty project in separate windows.
  5. Do the modern equivalent of a Monk, Painstakingly copy by hand the code out of the old files, create a new file in the new repo and paste the code in.
  6. Once all the files are copied over then do the first commit to your on computer repo and then do a push to the repo in your GitLab account.
  7. Do a merge/pull request from the old account to the new one and then go on from there.
  8. Archive the old repo on your computer and if desired delete it from the old user GitLab account.

Yes, I know I’ve lost all the git history leading up to the new user version but I finally realized that since the project spanned nearly 10 years and since I learned so much during that time that it might be best left in the past anyway. :slight_smile:

The big advantage is that it let me leave behind some sensitive files that should never have been included and craft a much better .gitignore file so they can’t get put in without extra effort.