Progress:
TIER 2 · MODULE 46· Intermediate

git credential-cache

Caches creds for a few minutes.

🎯 What & why

git credential-cache keeps credentials in RAM via a small daemon, expiring them after a timeout. Convenient for short sessions; gone after logout.

🧠 Mental model

A unix-socket daemon holds the secrets. Git asks it via the credential protocol. No disk. No keychain. Pure volatility — that's the whole point.

🛠️ Synopsis

git config --global credential.helper 'cache'
git config --global credential.helper 'cache --timeout=3600'
git config --global credential.helper 'cache --socket=/tmp/git-cred-sock'

git credential-cache exit   # kill the daemon now
git credential-cache <get|store|erase>   # plumbing

🎚️ Switches & options

FlagWhat it does
--timeout=<secs>How long to keep creds; default 900 (15 min)
--socket=<path>Custom socket location; default ~/.cache/git/credential/socket
getPlumbing: return cached cred for a description
storePlumbing: cache a cred
erasePlumbing: drop a cached cred
exit⚠️ Kill the cache daemon immediately, dropping all cached creds

📦 Subcommands

exit — Stop the daemon; everything cached is lost
git credential-cache exit
get — Internal — fetch a cred (Git calls this)
git credential-cache get < desc.txt
store — Internal — store a cred (Git calls this)
git credential-cache store < cred.txt
erase — Internal — drop a cred (Git calls this)
git credential-cache erase < desc.txt

💡 Use cases

🧪 Examples

Cache for one hour
git config --global credential.helper 'cache --timeout=3600'
Custom socket path
git config --global credential.helper 'cache --socket=$XDG_RUNTIME_DIR/git-cred'
Force-flush the cache
git credential-cache exit
Inspect by probing
printf 'protocol=https\nhost=github.com\n\n' | git credential fill

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.