Is there a way to cache https credentials for pushing commits?

Question:

I recently switched to synchronizing my repositories to https:// on GitHub (due to firewall issues), and it asks for a password every time. Is there a way to cache the credentials, instead of authenticating every time that git push?

Answer:

Since Git 1.7.9 (released 2012), there is a neat mechanism in Git to avoid having to type your password all the time for HTTP / HTTPS, called credential helpers. You can just use one of the following credential helpers:

The credential.helper cache value tells Git to keep your password cached in memory for a particular amount of minutes. The default is 15 minutes, you can set a longer timeout with:

You can also store your credentials permanently if so desired, see the other answers below.

GitHub’s help also suggests that if you’re on Mac OS X and used Homebrew to install Git, you can use the native Mac OS X keystore with:

For Windows, there is a helper called Git Credential Manager for Windows or wincred in msysgit.

With Git for Windows 2.7.3+ (March 2016):

For Linux, you would use (in 2011) gnome-keyring(or other keyring implementation such as KWallet). Nowadays (2020), that would be (on Linux)