git config credential.helper store

C++
// local
git config credential.helper store
// global
git config --global credential.helper store# this will store your credentials "forever"
git config --global credential.helper store$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

[several days later]
$ git push http://example.com/repo.git
[your credentials are used automatically]
Source

Also in C++: