Recently I needed to move one of my projects from Gitlab to Github. If you also want to do something similar here is a guide for you. Note that although I am using Gitlab and Github as an example, you can do this for moving your remote repository from any provider to any other or from any remote repo to another.
Technically we are actually not “moving” anything. All we are doing is to change where our repository’s
origin points to.
First we start by looking at the remotes on our local git repo:
This means that we have a remote called
origin that we can do pull(fetch) from and push to. In this example
origin points to a repo on Gitlab. Using the following command we tell origin to point to a new repo on Github instead:
That’s it! If we list the remotes again we will see that the new address is set:
Now we can do a push and we are good to go!