Avoid entering password all the time in git (github or bitbucket)

There comes a time, when you decide to grow up and use git properly. That necessarily means committing more and push more.

But this user password prompt will quickly drive you nuts

In order to keep at it you will want to setup automatic authentication for your git pull requests.

Whether you are using GitHub or Bitbucket, the process is the same.

Go to your account(s) and register a trusted public SSH key. The name you provide for that key should somehow allow you to map to the client it was generated by (e.g. Macbook or Ubuntu etc.). Note that the same key can be used for different accounts.

One last important thing is to use the SSH protocol for your remote and not the HTTPS anymore. The ssh protocol looks something like this:

git remote add origin git@github.com:myusername/myrepo

From now on, Github or Bitbucket will have your SSH public key with which they will encrypt a top secret message which they will send you. Since your private key is the only one that can decrypt what has been encrypted with your public key (the one you saved on your GitHub and Bitbucket accounts), it means that if you are able to send back the top secret message to GitHub or Bitbucket, then they know you are you. So they can grant you access.