Migrating to a new git service/repository
Feb 15, 2020 3:18 PM (10 months ago)

# Migrating to a new git service/repository

In one of the recent projects I am working on, we are migrating from a private Git server to GitHub. The easiest way to achieve this is to checkout all the code locally, including all the remote branches, then push to the new remote.

To do that start with a git fetch then just execute the following 👇🏻 code on your terminal in the project folder.

for remote in `git branch -r | grep -v master`; 
do git checkout --track $remote; done

Check the remotes with

git remote -v

Replace the remote url

git remote set-url origin https://path-to-your-repo@github.com

Then

git push --all

Done. 💪🏻