Overview
This Git configuration uses the GitHub CLI (gh) for credential management, sets sensible defaults for performance and usability, and configures Neovim as the default editor.
Configuration Location
Main config:~/.gitconfig (or ~/dot-gitconfig in dotfiles)
Credential Management
GitHub CLI handles authentication for GitHub and Gist:Setting Up GitHub CLI
- Install
- Authenticate
- Verify
Fedora:Ubuntu/Debian:macOS:
Why GitHub CLI?
- No password prompts: Automatic token management
- Two-factor auth: Handles 2FA seamlessly
- Multiple accounts: Switch between accounts with
gh auth switch - SSH key management:
gh ssh-keycommands
User Configuration
Editor Configuration
Alternative Editors
HTTP Configuration
Performance Settings
- postBuffer: Increases buffer for large repositories (500 MB)
- HTTP/1.1: Uses HTTP/1.1 for better compatibility
- lowSpeed settings: Prevents timeout on slow connections
- Large repositories with big binary files
- Slow or unstable network connections
- Pushing large commits
Repository Initialization
main as the default branch for new repositories (instead of master).
Useful Aliases
Add to~/.gitconfig for productivity:
Using Aliases
Additional Recommended Settings
Auto-correct Typos
Color Output
Rebase by Default
git pull --rebase by default for cleaner history.
Default Push Behavior
- Pushes current branch to remote with same name
- Automatically sets up remote tracking
Merge Tool
SSH Configuration
Prefer SSH over HTTPS:Always Use SSH
Per-Repository Configuration
Override global settings in specific repos:.git/config (not ~/.gitconfig).
FAQ
Authentication failing?
Authentication failing?
Check GitHub CLI status:If logged out:Refresh credentials:
Slow clone/push/pull?
Slow clone/push/pull?
Increase HTTP buffer:Or switch to SSH:
How do I use different email for work repos?
How do I use different email for work repos?
Use conditional includes:Create
~/.gitconfig-work:How to sign commits with GPG?
How to sign commits with GPG?
Generate GPG key:Add to GitHub:Configure Git:
Default branch still 'master'?
Default branch still 'master'?
Set globally:Rename existing branch:
Complete Example Configuration
Global Gitignore
Create~/.gitignore_global:
Related Configuration
- See Fish Shell for Git abbreviations
- See Neovim for editor integration
- See GitHub CLI docs for
ghcommands