Migrate from github enterprise to github.com - github

We have a few repositories and forks on a trial version of Github Enterprise. I want to evaluate how to migrate from Github enterprise to Github.com (into a paid for organization, say)
The only resource I found was how to perform the migration in the opposite direction
https://help.github.com/enterprise/2.0/admin/articles/moving-a-repository-from-github-com-to-github-enterprise/
I have contacted github.com asking the same questions as below and I am waiting for their response.
How do we migrate a repository from github Enterprise to github.com? (fairly certain that a git clone --bare and a git push --mirror will do the job)
If I migrate forks as well, how do we make sure that the relationship between the original and forks is maintained?
How do I migrate the webhooks and services we configured for our repositories?
How do I transfer the Pull requests/Issues? (article I linked to above says we need to use the Github API, I am OK with this solution)
Can we migrate teams and users? (guessing, probably not)
Note that we have the backups of the enterprise instance performed using the backup tools provided by github (I think it is called ghe-backup)
Thanks

You should be able to use the steps in the linked document in the reverse order as well:
Create an empty repository at github.com
Create a clone of the enterprise repository on your local.
Add github.com as a remote reference on your local clone.
Push all references to the github.com repository.

http://www.alexhadik.com/blog/2016/5/26/migrating-github-repositories-with-gitmover appears to offer a solution: GitMover is "a simple Python script that takes Git repos on any type of GitHub installation, and copies issues, labels and milestones from one to the other. It's the perfect tool to help automate the open-sourcing of an internal project."

Related

Bitbucket to github migration of an already existing repo

we have migrated from bitbucket to github 4 months ago but our team members are still using bitbucket. So, now we have decided to completely moved to Github and use its sevices. So, i want to know whether we can still use mirroring or not to migrate all the changes in bitbucket to github or we have to push it manually or using git push --all.
It depends if there was concurrent activity both on GitHub (the new repository) and BitBucket (the old one)
If that is the case, I would prefer asking each developer, in their own local repository, to:
add the new repository as a remote 'gh'
fetch from it
rebase their branch on top of gh/their-branch (for branches that were modified both on GitHub and BitBucket)
push new branches (done only on BitBucket)
That way, each developer can resolve any conflict locally first, before updating the new GitHub repository.

Copy the entire master branch from one GitHub enterprise server to another GitHub enterprise server in a different location

We have two hosted GitHub enterprise servers on VMWare servers in a distinct location. We would like to copy all master branch from one GitHub enterprise server to another GHE (maybe every day once). Also, we need to configure alerts to notify in case of copy failure, network issues, etc.
Could you please help me to implement this?
git clone --bare https://github-dev.assr.com/assr-ghactions/setup-java.git
git push --mirror https://github-qa.assr.com/assr-ghactions/setup-java.git

How do I mirror Github page for local browsing?

Let's say I have an internal web server (nginx) and I want it to serve a page with the content of the GITHUB repository, e.g. https://github.com/vibranze/test. Page from the repository must be served locally.
I've tried the article from https://help.github.com/articles/duplicating-a-repository/ but the synced repository is not browseable due to no index file.
How do I make the local repo browseable internally and looks exactly the same like what its master copy in github.com or if I've done it wrongly, what's the correct way to achieve it?
Any pointer or advice are greatly appreciated.
Thank you.
Short answer:
You need a local Git server which hosts a clone of your example repository from GitHub.
If your local Git server includes a web UI, you can probably see something similar like what you see on GitHub.
If you want future changes in the GitHub repo in your local repo as well, you need to pull periodically from the GitHub repo to your local repo.
Long version:
1. Hosting Git repos on your local server
There are a lot of options (paid and free) for running a Git server on your own machine.
Some of them contain web UIs which look similar (but not exactly the same) like GitHub.
There's only one option to get 100% the same look: by spending money for a private installation of GitHub (but it's not cheap).
If you don't want to spend that much, there are free alternatives, for example GitLab. This is a hosted service like GitHub, but the code is open source and you can install a free version on your local server.
Here's an example of a "repository overview" page:
https://gitlab.com/gitlab-org/gitlab-shell
GitLab is only one example, there's a lot more - just google for "self hosted git" and you will find plenty.
2. Getting a clone of the repository from GitHub to your local server
To set this up, clone the repo from Github to your local machine once with the --mirror option:
git clone --mirror https://github.com/user/repo some/local/path
To update your local repo with the newest changes from GitHub, you need to run git remote update periodically.

Un-fork GitHub project into new GitHub project not associated with the original [duplicate]

How can I make GitHub forget or disassociate that my repo was originally a fork of another project?
I forked a project in GitHub. I can now see "forked from whatever/whatever". The parent repository "whatever/whatever" is no longer maintained. I have been allowed to continue use of the code base of the original repository to create an independent repository.
Is there a way to detach my project from the original repository?
Update Jan 2022:
Use the GitHub chatbot-virtual-assistant at https://support.github.com/contact?tags=rr-forks&subject=Detach%20Fork&flow=detach_fork
First answer:
You can contact github support and ask them to switch your repository to "normal mode".
On this page, "Commit was made in a fork" paragraph, it is explained that one has to go through support to switch. Therefore, it is likely that there is no way to do that by yourself (unless you destroy and recreate your repo which is explained before... if you do so be careful if you have tickets or a wiki attached to your project as they will be deleted!).
You could duplicate the forked repository to a new repository (without the fork dependency) from the GitHub UI, then remove the original forked one:
Sign in to GitHub
Select the + sign in the top right corner and select Import repository.
Import your forked repository. The new repository won't have the fork dependency.
Delete the original, forked repository in the repository settings.
NOTE: This approach will not preserve issues and pull requests.
Make sure you have all the important branches and tags on your local repo, delete the github repo, recreate the repository through usual means (no forking) and push the local repository back with git push --all. Note that if you have local branches that you don't want to publish, might be worth to create a temporary clean local clone for the operation.
However, this will also get rid of wiki and issues. As the wiki is in fact it's own repository, it can be handled similarly by cloning it and then recreating and pushing. The repo address is on wiki's Git Access page (git#github.com:user/repo.wiki.git).
This leaves issues. They can be exported through the API, but as far as I know, you can only create issues and comments with your person, so importing them perfectly is impossible.
So, if you need issues to be preserved, you should go through github support as Thomas Moulard suggests.
I got the similar problem, and ended up using this github help page to solve it. I didn't mind about the wiki and issues tracker as it was for my blog using a theme kindly developed by another user.
To detach a forked repo and use it as your own after several commits without losing the whole history:
git clone --bare git#github.com:user/forked_repo.git
Create a new empty reposity new-repository on the github website.
And push a mirrored version:
cd user.github.com.git/
git push --mirror git#github.com:user/new-repository.git
One can rename on github, the forked_repository with another name to keep it as backup and check updates if needed. Or simply delete it.
Renaming the new-repository to the original name does the job. As a side effect, your commits now appear in your history.
Log in to GitHub with your credentials.
Go to https://support.github.com/contact?tags=rr-forks&subject=Detach%20Fork&flow=detach_fork.
Choose "Detach", then enter the URL or repo name of the fork as your-user-name/repository-name, and answer the other questions of the virtual assistant.
You will get an email with a ticket number where you can check the status of your request. You will also be notified per email once your repo has been deforked.
Most repository settings will stay unchanged, including user permissions, stargazers, issues, PRs, discussions, etc.
Using the info from aurelien and Clayton, I was able to do this with the following:
$ git clone --bare https://github.com/my/forked_repo.git
<delete forked_repo on GitHub>
<recreate repo on GitHub using same name>
$ cd forked_repo.git
$ git push --mirror
Here's the documentation for git clone --bare:
Make a bare Git repository. That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> itself the $GIT_DIR. This obviously implies the -n because there is nowhere to check out the working tree. Also the branch heads at the remote are copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking branches nor the related configuration variables are created.
Here's the documentation for git push --mirror:
Instead of naming each ref to push, specifies that all refs under refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.
Note: like the other git based answers, this will not copy over issues that are not part of the git repo such as the wiki and issues. Per Tapio:
The wiki is a separate git repo and can be handled in a similar fashion per Tapio. The address is: git#github.com:user/repo.wiki.git.
Issues can be exported via the GitHub API but there are issues recreating them since they can only be created by your user, so imports will lose information.
This only applies to GitHub Enterprise, not on github.com
Logged in to an account that has admin privileges:
Go to the repository that you need to detach: https://<ghe url>/<org>/<repo>
Click on the “Site Admin” rocket on the top right corner
Click "Collaboration" on the top menu bar
Click on “Network” on the left pane
Click on “Make Root” in the Network Structure pane
Accept
This was tested on GitHub Enterprise 2.9
If you do not need any past commits (I didn't in my case), you can just:
fork the project
make a local copy of the fork (I used my IDE to do that)
delete the git folder from your local copy
commit the project as you normally would a new project.
You can just delete the fork from your github account after. Took me all of one minute and worked like a charm.

Migrate repository from GitHub Enterprise to GitHub [duplicate]

We have a few repositories and forks on a trial version of Github Enterprise. I want to evaluate how to migrate from Github enterprise to Github.com (into a paid for organization, say)
The only resource I found was how to perform the migration in the opposite direction
https://help.github.com/enterprise/2.0/admin/articles/moving-a-repository-from-github-com-to-github-enterprise/
I have contacted github.com asking the same questions as below and I am waiting for their response.
How do we migrate a repository from github Enterprise to github.com? (fairly certain that a git clone --bare and a git push --mirror will do the job)
If I migrate forks as well, how do we make sure that the relationship between the original and forks is maintained?
How do I migrate the webhooks and services we configured for our repositories?
How do I transfer the Pull requests/Issues? (article I linked to above says we need to use the Github API, I am OK with this solution)
Can we migrate teams and users? (guessing, probably not)
Note that we have the backups of the enterprise instance performed using the backup tools provided by github (I think it is called ghe-backup)
Thanks
You should be able to use the steps in the linked document in the reverse order as well:
Create an empty repository at github.com
Create a clone of the enterprise repository on your local.
Add github.com as a remote reference on your local clone.
Push all references to the github.com repository.
http://www.alexhadik.com/blog/2016/5/26/migrating-github-repositories-with-gitmover appears to offer a solution: GitMover is "a simple Python script that takes Git repos on any type of GitHub installation, and copies issues, labels and milestones from one to the other. It's the perfect tool to help automate the open-sourcing of an internal project."