credential-store Git Command Guide
The git credential-store command provides a credential helper that stores Git credentials in plain text format in the user’s home directory. It’s a simple persistent storage mechanism, but stores credentials unencrypted, so use only on trusted machines.
git credential-store Syntax:
Section titled “git credential-store Syntax:”git credential-store <action>Actions:
Section titled “Actions:”| Action | Description |
|---|---|
| get | Retrieve credentials for given parameters |
| store | Store given credentials for future retrieval |
| erase | Remove stored credentials |
Options:
Section titled “Options:”| Option | Description |
|---|---|
| —help | Display help information |
| —file | Use specified file instead of default ~/.git-credentials |
Parameters:
Section titled “Parameters:”| Parameter | Description |
|---|---|
| Input from stdin for get/store actions: | protocol, host, path, username, password |
git credential-store Command Samples:
Section titled “git credential-store Command Samples:”Enable credential store globally
Section titled “Enable credential store globally”git config --global credential.helper storeConfigures Git to use store helper for all repositories.
Store credentials manually
Section titled “Store credentials manually”echo "protocol=httpshost=github.comusername=your-usernamepassword=your-password" | git credential-store storeSaves credentials to ~/.git-credentials file.
Retrieve stored credentials
Section titled “Retrieve stored credentials”echo "protocol=httpshost=github.comusername=your-username" | git credential-store getOutputs stored credentials for given parameters.
Erase stored credentials
Section titled “Erase stored credentials”echo "protocol=httpshost=github.comusername=your-username" | git credential-store eraseRemoves credentials from store for specified parameters.
Use custom credential file
Section titled “Use custom credential file”git config --global credential.helper 'store --file ~/.git-private-credentials'Specifies custom location for credential storage.
How do I set up Git credential store?
Section titled “How do I set up Git credential store?”To set up Git credential store, use:
git config --global credential.helper storeHow can I view stored credentials?
Section titled “How can I view stored credentials?”To view stored credentials, read the file:
cat ~/.git-credentialsHow do I store credentials manually?
Section titled “How do I store credentials manually?”To store credentials manually, run:
echo "protocol=https\nhost=example.com\nusername=user\npassword=pass" | git credential-store storeIs credential store secure?
Section titled “Is credential store secure?”Credential store saves credentials in plain text, making it suitable only for secure, personal environments.
How do I erase stored credentials?
Section titled “How do I erase stored credentials?”To erase stored credentials, use:
echo "protocol=https\nhost=example.com\nusername=user" | git credential-store eraseApplications of the git credential-store command
Section titled “Applications of the git credential-store command”- Permanent credential storage for personal development machines
- Simplifying authentication in trusted development environments
- Supporting automation scripts with persistent credentials
- Integrating with password management tools for plain text export
- Enabling seamless Git workflows on secure workstations
- Managing multiple repository credentials across different services