0

So, we would like to transfer a GitHub repo from an individual account to an organization. Easy enough, but the only issue is that we don't remember the password to the account and the recovery email was linked to a work email that we no longer have access to.

Of course, we could always just manually transfer the code to a new repo, but then we lose all of the issue-tracking and history of the repo. Alternatively, we could fork the repo to a new organization, but then I think it's forever labelled as a fork on the original repo, correct?

Is there a better option?

DanHickstein
  • 6,588
  • 13
  • 54
  • 90
  • 1
    Do you have a local copy anywhere where someone has cloned the remote? You can just use that. Just [push it to a new remote](https://stackoverflow.com/questions/5181845/git-push-existing-repo-to-a-new-and-different-remote-repo-server). There's nothing special about the version in github. All the local versions are exact duplicates. – Liam Dec 09 '21 at 16:24
  • 3
    I think this is a question for github customer support – LeGEC Dec 09 '21 at 16:40
  • @Liam just pushing it back won't transfer the issues, pull requests, and all other meta data that GitHub keeps that is not part of the Git repo itself. – joanis Dec 09 '21 at 17:48
  • @DanHickstein the GitHub Migrations tool might do what you need. https://docs.github.com/en/repositories/archiving-a-github-repository/backing-up-a-repository I was investigating using it for backup purposes before, but I have not actually tried yet. – joanis Dec 09 '21 at 17:49
  • You can't use the migration tool if you don't have access to the account @joanis – Liam Dec 09 '21 at 19:27
  • @Liam Doh! nevermind... Thanks for pointing it out. – joanis Dec 09 '21 at 20:59

1 Answers1

0

The .git directory contains all the issue-tracking and history of the repo, not the GitHub account. So, as long as the .git directory is copied over, you'll have access to logs, past commits, etc. Just make sure to copy all the contents of the repo over, using your file explorer or something like cp /path/to/repo/. /my/new/path/

To use the repo with a org account, just manually change the email and the origin. On the computer you'll be using for all the operations below, generate an SSH key with ssh-keygen (press enter through the defaults) and go into your org account on GitHub, under "settings>SSH and GPG keys", and add the ssh key to your account. Create a repo with the same name as the repo you copied over.

First, you'll likely want to remove any of the remotes currently set on the repo. To display those remotes, use:

git remote -v

Delete them with:

git remote remove <name>

Then add the ssh address of your org's repo and push to it like so:

git remote add origin git@github.com:<your-org-name>/<your-repo-name>.git
git branch -M main
git push -u origin main
Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • Thanks for the recommendation! But there is no way that the .git directory contains the information on the Issues on GitHub, right? I mean, I can add a reply to an issue on GitHub and that won't change the actual repo... – DanHickstein Dec 09 '21 at 19:58
  • Ah, I see. If you have issues tracked on github that you want to retain, no, this method won't work. I think your only options are to fork the repo, or to call github customer support. Good luck. – bittahProfessional Dec 09 '21 at 20:10