How to Save Git Credentials on Windows, macOS, and Linux

A quick guide to configuring Git credential helpers so you never have to re-type your password or token.
Git
DevOps
Workflow
Author

Dev Author

Published

June 1, 2026

To save your Git credentials and stop typing your password every time, configure Git to use a credential helper.

Open your terminal or command prompt and run one of the following commands based on your operating system and security preferences.

Permanent Hard Drive Storage (Less Secure)

This saves your credentials indefinitely in a plaintext file (~/.git-credentials) on your disk. Only use this on trusted, private machines.

git config --global credential.helper store

⏱️ Temporary Memory Cache

This keeps your credentials safely in your computer’s RAM memory for a set period so they never touch your hard drive.

# Caches your credentials for 1 hour (3600 seconds)
git config --global credential.helper 'cache --timeout=3600'

How to Apply the Changes

To activate your new credential manager setting, follow these three steps:

  1. Run your chosen configuration command from the options above.
  2. Perform a remote operation like git pull or git push.
  3. Enter your username and password/token when prompted.

Git will securely save them for all future actions.

NoteGitHub Authentication

If you are pushing or pulling from GitHub, remember to use your Personal Access Token (PAT) instead of your account password when prompted by the terminal.