How to move git repository with all branches from bitbucket to github?

前端 未结 11 1783
孤城傲影
孤城傲影 2020-12-02 03:21

What is the best way to move a git repository with all branches and full history from bitbucket to github? Is there a script or a list of commands I have to use?

11条回答
  •  不知归路
    2020-12-02 03:57

    In case you want to move your local git repository to another upstream you can also do this:

    to get the current remote url:

    git remote get-url origin

    will show something like: https://bitbucket.com/git/myrepo

    to set new remote repository:

    git remote set-url origin git@github.com:folder/myrepo.git

    now push contents of current (develop) branch:

    git push --set-upstream origin develop

    You now have a full copy of the branch in the new remote.

    optionally return to original git-remote for this local folder:

    git remote set-url origin https://bitbucket.com/git/myrepo

    Gives the benefit you can now get your new git-repository from github in another folder so that you have two local folders both pointing to the different remotes, the previous (bitbucket) and the new one both available.

提交回复
热议问题