0

I refer to Git push: username, password, how to avoid? set my ssh key, it works.

But now, i clone another repository into my computer, once again i refer to that guide, copy the contents of my ~/.ssh/id_rsa.pub into the Deploy keys of this repository, github tell me 'Key is already in use'.

How can i avoid username and password in both two repository?

Community
  • 1
  • 1
vincent
  • 625
  • 1
  • 8
  • 20

2 Answers2

1

IF you're cloning repos for your own use (not deploying to server etc.) you should add your SSH key to your GitHub profile via https://github.com/settings/keys . Then there is no need to add separate keys for each repository.

Then, clone repository using SSH URL (not HTTPS). For example, if your repository is at https://github.com/youruser/yourrepo do git clone git@github.com:youruser/yourrepo.git.

ypcs
  • 91
  • 3
0

Once you have added the ssh key(id_rsa.pub) of your local machine to Github. Then you should always clone the respository using ssh instead of https.

git clone https://github.com/user_name/repo
git clone git clone git@github.com:user_name/repo.git

Always avoid first if you have added the ssh key.

Shravan40
  • 8,922
  • 6
  • 28
  • 48