Running Git Pull, Commit, Push Without Re-authenticating (SSH, Credential)
Every pull, commit, and push prompts for credentials by default — configure SSH keys or a credential helper once to eliminate repeated authentication.
[01] Two Ways to Store Git Credentials
| Method | How it works | Best for |
|---|---|---|
| SSH Key | Generate a key pair; register the public key with Git host | Permanent, passwordless auth per machine |
| Git Credential Helper | Cache credentials after first login | HTTPS-based workflows; temporary or permanent storage |
[02] Register and Use an SSH Key
2-1. Generate an SSH key
1
2
3
4
5
# Accept the defaults (press Enter for each prompt)
ssh-keygen -t rsa -C "Git" -b 4096
# Print the public key to copy
cat ~/.ssh/id_rsa.pub
Sample output:
1
2
root@cmaven:~# cat ~/.ssh/id_rsa.pub
ssh-rsa AAAA124123QABAAACAQCbKx1YXw8bUIWUb39eLkm7+AMVT92PhMCo...
Copy the entire line starting with ssh-rsa.
2-2. Register the SSH key with your Git host
Navigate to: Profile → Settings → SSH and GPG Keys → New SSH Key → Paste the key → Add SSH Key
Figure 1. SSH Keys settings page
Figure 2. Adding a new SSH key
2-3. Clone the repository over SSH
When cloning, use the SSH URL (starts with git@) instead of HTTPS:
Figure 3. Selecting the SSH clone URL
From this point onward, pull, commit, and push run without authentication prompts.
If your repository was already cloned via HTTPS, update the remote URL:
git remote set-url origin git@github.com:<user>/<repo>.git
[03] Using Git Config (Credential Helper)
Run these commands from inside any Git repository on your development machine. Authenticate once with your ID and password (or token); subsequent operations run without re-authentication.
3-1. Permanent storage
Credentials are saved in plain text to ~/.git-credentials.
1
2
3
4
git config credential.helper store
# Verify the change
git config --list
3-2. Cache storage (time-limited)
Credentials are held in memory only — nothing written to disk.
1
2
3
4
5
# Default: 15 minutes
git config credential.helper cache
# Custom timeout (e.g., 1 hour = 3600 seconds)
git config credential.helper "cache --timeout=3600"
3-3. Apply globally to all projects
1
git config credential.helper store --global
3-4. Comparison
| Helper | Storage location | Expires | Security |
|---|---|---|---|
store |
~/.git-credentials (plain text) |
Never | Lower |
cache |
Memory (tmpfs socket) | After timeout | Higher |
| SSH key |
~/.ssh/ (key file) |
Never | Highest |
On macOS, use
osxkeychainas the credential helper to store credentials in the system Keychain:git config --global credential.helper osxkeychain. On Windows,wincredor the Git Credential Manager (GCM) is recommended.