[git] Using SSH On An Existing Repository Already In HTTP

There are plenty of times when I’ve setup or cloned a project in HTTP originally, and then later, needed to connect via SSH. Here are the ways to modify it :

1/ When creating a project

  • Using HTTP:
    git remote add origin https://github.com/nickname/repository.git
    
  • Using SSH:
    git remote add origin git@github.com:nickname/repository.git
    

2/ Updating an existing project

  • Open .git/config file, find the [remote “origin”] line;
  • Change the url from :
    https://github.com/nickname/repository.git

    to :

    git@github.com:nickname/repository.git

Of course, you must have your SSH keys registered in your Github/Bitbucket account.

Advertisement

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

%d bloggers like this: