Changing GitHub project origin

You may need to change a GitHub origin definition in the client-side, some reasons to do this are:

  • the repo name changed;
  • you want to switch from HTTPS to SSH or vice-versa.

Imagine I want to change my authentication method from HTTPS to SSH, the HHTPS URL I want to replace is:

https://github.com/sparkfireworks/spark-fireworks.git

the SSH URL want to start using is:

git@github.com:sparkfireworks/spark-fireworks.git

Start by listing current origin:

$ git remote -v
origin  https://github.com/sparkfireworks/spark-fireworks.git (fetch)
origin  https://github.com/sparkfireworks/spark-fireworks.git (push)

Now remove the origin no longer in use:

$ git remote remove origin

Finally add the new SSH URL:

git remote add origin git@github.com:sparkfireworks/spark-fireworks.git

Now check you successfully switched to SSH:

$ git remote -v
origin  git@github.com:sparkfireworks/spark-fireworks.git (fetch)
origin  git@github.com:sparkfireworks/spark-fireworks.git (push)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s