Most Elegant Way To Transfer Repositories From Personal Account To Organization #188227
-
Select Topic AreaQuestion BodyHello, I currently have a couple of projects I'd like to move to my new organization. I think what I am looking for is confirmation on several potential pitfalls. One of which, I assume, is that the Packages (aka Docker Images from GHCR) won't be migrated. Is this still the expected behaviour or are the threads I've read stale? Additionally, if I were to do such a thing and move the repositories, what would be the best way to go about it with minimal chaos. I want to plan this move first so that I don't run into more gotchas than a manageable amount. My projects are still early enough that a lot of users are not downloading said packages but let's say they are and they come looking, should I just have a new repository of the same name (after migration) that sends them to the one on the organization? It's unclear and I don't want to jump into it without doing thorough research hence this thread. I also feel this is a huge security flaw and opens the door for potential (albeit a lot of hoops might be required to get there) repojacking or name hijacking since a lot can happen if you let go of a name. Again, the chances are low but not non-zero. I have been reading the documentation as well as threads here and there. But perhaps, my question is,
Cheers and thanks in advance. Some notable references I've read: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Subject: Best Practices for Repository and GHCR Package Migration to Organizations Moving projects to a new organization is a common milestone, but you are correct to be cautious about the "connective tissue" like GitHub Packages (GHCR) and security implications. Based on current GitHub behavior and documentation, here is a detailed breakdown of how to handle this elegantly.
Manual Migration: You must use the GitHub API or CLI to connect the package to the repository after the repo has moved. Permissions: Ensure the Organization has "Write" access to the package. If the package is currently "Private," you will need to re-configure the pull secrets in your deployment environments (K8s, CI/CD, etc.) because the namespace in the image path will change from ghcr.io/old-username/repo to ghcr.io/new-org/repo.
Git Remotes: GitHub will automatically redirect git clone and git push requests from the old URL to the new one. However, it is best practice for contributors to update their remotes manually: git remote set-url origin [new-url]. Action Secrets: Repository-level secrets move with the repo, but Environment secrets and Organization-level secrets do not. You must recreate any CI/CD secrets in the new Organization. Pages: If you use GitHub Pages, the custom domain will transfer, but the underlying *.github.io URL will change immediately.
The Elegant Solution: Perform the transfer. Do not create any new repositories with the old name. GitHub protects the namespace of a transferred repository as long as you don't manually interfere with it by creating a new repo of the same name.
Recommended Action Plan: Pre-Pull: If you have production services running, ensure they have the images cached or update their pull configs immediately after the move. Transfer: Use the GitHub UI/Settings to transfer the repo. Reconnect Packages: Go to the Package settings in your personal account and change the "Inherit access from repository" to the new repo location in the Org. The most "elegant" way is to treat this as a scheduled maintenance window: Update the repo, reconnect the package, and update your image paths in one clean sweep. Cheers! source: https://docs.github.com/en/repositories/creating-and-managing-repositories/transferring-a-repository |
Beta Was this translation helpful? Give feedback.
Subject: Best Practices for Repository and GHCR Package Migration to Organizations
Hello,
Moving projects to a new organization is a common milestone, but you are correct to be cautious about the "connective tissue" like GitHub Packages (GHCR) and security implications. Based on current GitHub behavior and documentation, here is a detailed breakdown of how to handle this elegantly.
You are correct: Packages (Docker images in GHCR) do not automatically move with the repository. When you transfer a repository, the GitHub Container Registry (GHCR) remains linked to the original namespace (your personal account) unless explicitly migrated. To move them:
M…