Managing multiple GitHub accounts on a single machine can be a challenge, but it's achievable with the right approach. GitHub uses SSH keys for verification, which can get confusing when you have multiple accounts with different keys. The solution lies in a config file within your .ssh directory, where you can create profiles for each account. This allows your computer and GitHub to recognize which key belongs to which account.

To set it up, generate unique SSH key pairs for each account using the ssh-keygen command, and add the public key to the corresponding GitHub account settings. Then, create a config file in your .ssh directory with separate blocks for each account. When cloning repositories, use the Host you defined in the config file to specify which account to use.

This approach can be applied not just to GitHub but also to other Git providers like GitLab and Bitbucket with minor changes. By using templates, you can quickly answer FAQs or store snippets for re-use.

Source: https://dev.to/varungujarathi9/multiple-github-accounts-on-one-machine-4abb

Reply to this note

Please Login to reply.

Discussion

No replies yet.