Ever wondered how to work with the GitHub account associated with a different email address than the one set-up in your machine? We can do it with SSH Key.
In this article, we will see how to set up a GitHub repository with SSH.
Step 1 - Create an SSH Key
ssh-keygen -t ed25519 -C "<your email address>"
Step 2 - Copy the SSH Key
clip < <path of the ssh key>
Step 3 - Add SSH key to the GitHub account
- Go to the URL https://github.com/settings/ssh/new
- Add the Title of the key.
- Paste the key in the Key field.
Step 4 - Check if the SSH Key is validated
ssh -T git@github.com
Step 5 - Link the GitHub repo to the SSH Key
git remote set-url origin git@github.com:<your username>/<repository name>.git
Step 6 (Optional) - Set git username and email
git config user.email "<your email address>"
git config user.name "<your name>"
You can now perform the Git operations for your repository.
Top comments (0)