gitgithubssh

How to migrate from HTTPS to SSH github


I cloned my company project repo using HTTPS, I want to migrate into SSH because it conflicts with my personal git account. how can I migrate into SSH instead of using HTTPS?


Solution

  • Steps

    1. Create an ssh key ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

      Enter passcode and then copy it pbcopy < ~/.ssh/id_rsa.pub If you don't have pbcopy, xclip or vim just type: cat ~/.ssh/id_rsa.pub

      add it into your GitHub: Adding a new SSH key to your GitHub account

    2. remove GitHub credentials (if you were using HTTPS there is a high possibility GitHub credentials are saved in your system), we don't need those credentials since we are using SSH (Optional step)

    3. Change the remote URL to SSH

      git remote set-url origin <SSH url>
      

      example :

      git remote set-url origin git@github.com:username/repo_name.git
      
    1. Enter the passcode of your key

    2. Verify your remote url has been changed

      git remote -v