You want to configure your computer to be able to pull, push and fetch repositories without asking you to enter your username/password? You have to configure some little things that we did not set them in the beginning.
We need an SSH Key first!
First you have to provide a SSH key(I don’t know what SSH is), to generate a new key you can follow these commands (If you already have one skip this):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This command will generate a new SSH public and private key. You should NOT send your private key to anyone !!
If you take a look to the .ssh folder you will find two files id_rsa and id_rsa.pub (public).
Check if the SSH agent is running, this should return a PID:
eval $(ssh-agent -s)
To add the new generated key to the SSH agent you need this command:
ssh-add ~/.ssh/id_rsa
Configure your Github
Assuming that you already have a Github account. After copying your public key (the content of id_rsa.pub), go to setting > SSH and GPG keys > New SSH key and then copy/paste your public key. Then, you need to add Github host to SSH agent by running this command:
ssh-add -T git@github.com
Check if you cloned a repository using a SSH and not by HTTPS protocol in this file .git/config:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = https://github.com/user/repo.git # change it to git@github.com:user/repo.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "develop"] remote = origin merge = refs/heads/develop
1 Comment