I cloned my company project repository 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?
Steps
Create an SSH key: ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Enter a 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 space: Adding a new SSH key to your GitHub account
remove the 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)
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
Enter the passcode of your key
Verify your remote URL has been changed
git remote -v