Skip to main content

Change the origin of a Git repository

Published ago
Updated ago
1 min read

More than once I have needed to change the origin of a repository, so to make my life easier I decided to make the annotation here.

The first thing you need is a new repository, let's say it is git@github.com:emeaguiar/mah-theme.git

Now, the thing is as simple as removing the old origin remote, adding the new one, and configuring it as master.

1# Remove old origin
2~ git remote rm origin
3
4# Add new origin
5
6~ git remote add origin
7
8# Configure it as master
9
10~ git config master.remote origin
11

Done! Now when you run git remote get-url origin --all you will see the new repository.