Example:
migrate project A GitLabCE to project B GitHub
- Inside your GitHub team page, create an empty private repo with the same name of GitLab repo that you want to transfer.
git clone https://gitlab.hotromaytinhit.tech/hotromaytinhit/A.git - Copy your newly created repo link, either in HTTPS or SSH. For example, https://github.com/hotromaytinhit/B.git (SSH type)
- Inside your local project folder, change the remote URL under .git/config ‘s file to your copied GitHub’s one. The content looks similar as follows. [remote “origin”]
cd A
vim .git/config & change url project B github
url = https://github.com/hotromaytinhit/B.git
fetch = +refs/heads/:refs/remotes/origin/ - Do a git push: git push –all . It will push all codes and commit history on your newly GitHub repository.
- Done. After that, when we push new commits, it will push to GitHub only.
- Assume we are in your home directory
cd /home/hotromaytinhit - Clone the repo from GitLab using the
--mirror
option
git clone –mirror https://gitlab.hotromaytinhit.tech/hotromaytinhit/A.git - Change into newly created repo directory
cd /home/hotromaytinhit/A.git - Push to GitHub using the
--mirror
option. The --no-verify
option skips any hooks.
git push –no-verify –mirror https://github.com/hotromaytinhit/B.git - Set push URL to the mirror location
git remote set-url –push origin https://github.com/hotromaytinhit/B.git - To periodically update the repo on GitHub with what you have in GitLab
git fetch -p origin
git push –no-verify –mirror