'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 1:[1]
Steps
- Create an ssh key
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
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
remove GitHub credentials (if u 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 [email protected]:username/repo_name.git
Enter the passKey
Verify your remote url has been changed
git remote -v
Solution 2:[2]
You need to generate ssh key, add it to your profile and then change the url
Source: https://help.github.com/en/enterprise/2.15/user/articles/adding-a-new-ssh-key-to-your-github-account
Generating ssh key
- Open Git Bash.
- Run
ssh-keygen
and follow the on-screen messages (or simply click Enter till it over) Copy the key file (the content of the public key) located in:
~/.ssh/id_rsa.pub
Add key to Github
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | CodeWizard |