xlinsist xlinsist - 2 months ago 5x
Git Question

Git push: how to avoid username and password in multiple repository?

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?


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.