Transfer git repositories from GitLab to GitHub - can we, how to and pitfalls (if any)?

后端 未结 6 1619
生来不讨喜
生来不讨喜 2020-12-02 03:32

Can one transfer repositories from GitLab to GitHub if the need be. If so, how exactly can I go about doing the same?

Also, are there any pitfalls in doing so or pre

6条回答
  •  我在风中等你
    2020-12-02 04:16

    For anyone still looking for a simpler method to transfer repos from Gitlab to Github while preserving all history.

    Step 1. Login to github, create a private repo with the exact same name as the repo you would like to transfer.

    Step 2. Under "push an existing repository from the command" copy the link of the new repo, it will look something like this: git@github.com:your-name/name-of-repo.git

    Step 3. Open up your local project and look for the folder '.git' typically this will be a hidden folder. Inside the .git folder open up config

    The config file will contain something like:

    [remote "origin"]

    url = git@github.com:your-name/name-of-repo.git

    fetch = +refs/heads/:refs/remotes/origin/

    Under [remote "origin"], change the url to the one that you copied on github

    Step 4. Open your project folder in the terminal and run: git push --all This will push your code to github as well as all the commit history.

    Step 5. To make sure everything is working as expected, make changes, commit, push and new commits should appear on the newly created github repo.

    Step 6. As a last step, you can now archive your gitlab repo or set it to read only.

提交回复
热议问题