Is it possible to fork a GitHub project into a GitLab project and the other way around?
1 Answer
When creating a new repository, you can choose to import another repository, and one of the options is to import it via its https://... url from another repository site, such as github. This starts a git clone --bare <url> to import the repository. In the GitLab documentation the process is described in detail. Whenever I tried that, the process kept refreshing to the same "in progress" state indefinetly.
Update: This seems to work only for repositories you own. So to import a public repository, a workaround would be to fork it and import the fork.
So another way would be to clone the repository on the commandline before populating your new repository:
When you create a new, empty repository at your gitlab site, you get a page full of suggestions how to proceed to populate this repository.
Setting up a tracker for a github site is basically a variant of the
Existing Git repository recipe with the minor difference of cloning the repository to track first, and instead of renaming the previous origin to old-origin as suggested in the recipe, you want to rename it to upstream instead to maintain conventions. So you'll end up with proceedings as outlined:
- Clone the original repository you want to track:
git clone https://github.com/<author>/<repository.git> <repository>-tracker - Change into the directory the repository was cloned into
cd <repository>-tracker - rename the source (
origin) to something else (upstream), so you can still address it.git remote rename origin upstream - create your own repository located at your gitlab server, giving it a suitable name and description (don't miss to reference/link the original source there)
- add the url of your own gitlab repository as
origin. The exact line to use including the path to your own repository can be found in the Existing Git repository recipe you probably received as a result of the previous step.git remote add origin git@<gitlab-server>/<path-to-your-repo>.git - push the repository to your gitlab server:
git push -u origin --all git push -u origin --tags - afterwards:
git remote -v origin git@<gitlab-server>/<path-to-your-repo>.git (fetch) origin git@<gitlab-server>/<path-to-your-repo>.git (push) upstream https://github.com/<author>/<repository.git> (fetch) upstream https://github.com/<author>/<repository.git> (push)