I pull changes from my own repos on different places: my laptop, my home computer, my work computer, my router…
On every place, when fetching changes I have to enter my passphrase. That does not make much sense since most of the repositories can be fetched anonymously.
The issue can be analyzed from a different point of view. When do I need to authenticate myself? → Only on push.
One solution for that is pushInsteadOf. Since git v1.6.4, this option exists to specify what URL git should use when pushing changes. Now I need to change the URLs in all my repos to use by default the read-only URL: for example changing
https://github.com/borisfaure/bfb.git. I use
https since it should have a smaller impact on the servers than the git protocol.
Then I’ve added the following to my
[url "email@example.com:borisfaure/"] pushInsteadOf = https://github.com/borisfaure/ pushInsteadOf = git://github.com/borisfaure/
Those 3 lines work for all my github repos. An URL like
https://github.com/borisfaure/bfb.git will be rewritten to
No need to enter my passphrase when fetching changes!
Edit: You can also add an url for push using