Git change remote repo

Sometimes you start a git repo and some time later, you have to change your remote repo. This can be done really easy with a small catch:

Your new repo should be completely clean.

git remote -v
git remote set-url origin<NEW_USER>/<NEW_REPO_NAME>.git
git merge --allow-unrelated-histories FETCH_HEAD

This will work now:

git push

… and will transfer your old repo’s history to the new repo.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>