The parent has a great point about credentials and ssh-agent in general. Netrc isn't a great pattern.
But for git you have the right answer.
I completely forgot this aspect because on OS X you can delegate git auth to Keychain with a helper.
https://help.github.com/articles/caching-your-github-passwor...