Committing code in Github becomes pain because of it’s asking username and password nature for each and every commit to the repository, specially when you are doing frequent commits.
Github provides a remedy to overcome it through SSH Keys. We can simply create SSH Keys and ask Github to identify our computer and don’t ask for username and password for every commit. It can be easliy done in few steps:
Step 1: Open Git Bash and execute command:
Step 2: Next, execute below command, and keep on pressing press Enter, it will create default public SSH key.
ssh-keygen -t rsa -C "email@example.com" For example : ssh-keygen -t rsa -C "firstname.lastname@example.org"
Step 3: Turn on ssh-agent entering below command:
Step 4: Add generated SSH key to the ssh-agent:
Step 5: Go to directory /Users/you/.ssh and open the “id_rsa.pub” in notepad and copy the content. Now login to your Github account, click on Settings and from right panel click on SSH Keys. Now, click on Add SSH Key button and paste the “id_rsa.pub” content in it and give it any name you want.
Step 6: Testing the connection, execute below command:
ssh -T email@example.com
Now commit the code in Github using SSH or HTTPS and I am sure Github will not ask you to enter username and password.