Caching Github login credentials

Thursday, 7. May 2015

If you are new to Github and you are cloning your repository via HTTPs url, you will notice that Git will prompt you to specify login and password everytime you try to pull or push your changes to and from GitHub.

Obviously this is not ideal (especially if you push and pull often). Luckily as of Git 1.7.10 or newer you can use the credential helper feature to cache credentials for a specified time. This means, you only have to specify your login details once and git will cache those for the time duration you specify

To achieve this, all you need it to run the following command on your terminal window and you are done! Time is in seconds incase you want to change to something that works for you!

git config --global credential.helper 'cache --timeout=7200'
# Set the cache to timeout after 1 hour (setting is in seconds)

Hope this helps someone! Comments below if you have something better!