Changing the origin of a git repository

February 16th, 2012 21:10 – by Torsten Trautwein

If you need to change the origin of your git repository, you can do this quickly by following these steps:

Check out all the branches:

git checkout -t origin/branch
… 

Remove the old origin, add the new one:

git remote rm origin 
git remote add origin git@example.com:repository.git

Push all the master and all the other branches to your new origin:

git checkout master
git push -u origin master

git checkout branch
git push origin branch
… 

Configure some settings for your convenience (as necessary):

git symbolic-ref HEAD refs/heads/master
git remote set-head origin master
git config master.merge refs/heads/master
git config master.remote origin

Done.

Back

Get In Touch

The usual channels

twitter @neowork
Google+ +neowork
github neowork
500px neowork
E-Mail mail@neowork.com

Or send a message right away

captcha

Imprint

Torsten Trautwein
Pfannmuellerstr. 28
60488 Frankfurt am Main, Germany

mail@neowork.com
+49 (0)7000 NEOWORK
+49 (0)7000 63 69 675
max. 0.12 €/min on German landlines