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!

src refspec master does not match any : failed to push some refs

Thursday, 7. February 2013

I have had this error after moving repository to another account. There are various factors that may cause such problem but since I was sure our git framework covered all the basics, i was a little suprised as to why I keep having this issue.

error: src refspec master does not match any.
error: failed to push some refs to '/path/repo.git'

After a bit of cross referencing, I indeed notice the head information was not being created when we initiated repository under the new account under (your_repo.git/refs/heads)

In the end it turned out the issue was simply because there was no user details registered in git config for the account we were currently using. So afterall the frameworks was not covering all the basics by the looks of things!! :)

Anyway, to solve it.. simply add the following basic details and you will be sorted

git config --global "YOUR NAME"
git config --global "YOUR EMAIL"