credential-cache Git Command Guide
The git credential-cache command provides a credential helper that caches Git credentials in memory for a specified period. It’s useful for avoiding repeated credential prompts during a development session while remaining more secure than permanent storage.
git credential-cache Syntax:
Section titled “git credential-cache Syntax:”git credential-cache [daemon [--options]] [<action>]Options:
Section titled “Options:”| Option | Description |
|---|---|
| —timeout | Number of seconds to keep credentials cached (default 900 = 15 minutes) |
| —socket | Path to socket file where daemon will listen |
| —help | Display help information |
Actions:
Section titled “Actions:”| Action | Description |
|---|---|
| (none) | Contact daemon to get/store credentials |
| daemon | Start the daemon (usually done automatically) |
| exit | Shut down credential cache daemon (kills all children) |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| Timeout in seconds for credential caching |
git credential-cache Command Samples:
Section titled “git credential-cache Command Samples:”Enable credential caching globally
Section titled “Enable credential caching globally”git config --global credential.helper cacheConfigures Git to use the cache helper.
Start daemon with custom timeout
Section titled “Start daemon with custom timeout”git credential-cache --timeout 3600 daemonStarts cache daemon with 1-hour timeout.
Exit cache daemon
Section titled “Exit cache daemon”git credential-cache exitStops the credential cache daemon.
Configure cache timeout
Section titled “Configure cache timeout”git config --global credential.helper 'cache --timeout 1800'Sets cache timeout to 30 minutes globally.
How do I enable Git credential caching?
Section titled “How do I enable Git credential caching?”To enable Git credential caching, use:
git config --global credential.helper cacheHow can I set the credential cache timeout?
Section titled “How can I set the credential cache timeout?”To set the credential cache timeout, run:
git config --global credential.helper 'cache --timeout 1800'How do I stop the credential cache daemon?
Section titled “How do I stop the credential cache daemon?”To stop the credential cache daemon, execute:
git credential-cache exitWhat is the default timeout for credential cache?
Section titled “What is the default timeout for credential cache?”The default timeout for credential cache is 15 minutes (900 seconds).
Is credential cache secure?
Section titled “Is credential cache secure?”Credential cache stores credentials in memory temporarily, making them inaccessible after session ends or timeout expires.
Applications of the git credential-cache command
Section titled “Applications of the git credential-cache command”- Reducing credential prompts during intensive Git workflows
- Supporting automated scripts that perform multiple Git operations
- Temporary credential storage for development sessions
- Balancing convenience and security in team development
- Enabling smooth experience in environments with frequent credential changes
- Supporting CI/CD pipelines that need short-term credential persistence