G'day Internet.
Two weeks ago my company migrated from Github Entreprise to Github Enterprise Cloud. All the migration went well. Only today I realised that two of my private repositories were not migrated. Luckily enough a colleague of mine pointed me towards a solution (thanks Dario). And here I share this solution with you.
Making a simple copy of the repository and pushing it to a new repository in the cloud was a solution, but not a good one. Why? Because all the history of the repository is lost. Our solution does not only copy the codebase, but also the history.
First we want to retrieve the old repository. In a terminal, run the following command.
λ git clone --mirror git@company.com/repository.git
Note the --mirror option: it creates a repository.git
folder with both the codebase and the history.
Before running the next commands, we need to create an empty repository in github cloud. If you wanted to change the name of you repository, now is a good time. For this example we will keep the name repository
.
Once it is create run the following commands
λ cd repository.git
λ git push --mirror git@github.com:company/repository.git
We should now be able to see our repository in github cloud populated with the codebase and the history.
When pushing to the new repo we could encounter the following error
! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
This is likely because a pull request was opened in the previous repository. It does not stop the repository being copied, it just does not copy the pull request.
That's all folks, I hope this helps.
Jon
Top comments (0)