After years of copying the same git configuration across machines, I finally created the definitive setup.
Today, I'm sharing it with you.
The Problem
Every developer faces this:
- New machine = hours of git configuration
- Forgetting which settings made things faster
- GPG signing is complicated
- Inconsistent workflows across teams
- Slow git operations on large repos
The Solution
A production-ready git configuration that emphasizes:
π Security - SSH commit signing, no more GPG complexity
β‘ Performance - 10x faster operations on large repos
π¨ Developer Experience - 25+ useful aliases
π¦ Modern Standards - XDG compliance, conventional commits
Key Features
1. SSH Commit Signing Made Simple
SSH signing is way simpler than GPG. You already have SSH keys for GitHub/GitLab authentication. Just use the same key for signing!
Benefits:
- No separate keyring to manage
- Works with GitHub and GitLab
- Simple setup (2 minutes)
- "Verified" badge on all commits
Setup:
# Use your existing SSH key
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/id_ed25519.pub
git config --global commit.gpgsign true
2. Performance That Actually Matters
The configuration includes settings that make git operations significantly faster:
Key optimizations:
-
core.fsmonitor = true- Use filesystem events (10x faster status) -
core.untrackedCache = true- Cache untracked files -
core.commitGraph = true- Faster log operations -
protocol.version = 2- Modern git protocol -
index.version = 4- Compressed index
Real-world impact:
- Before:
git statustakes 3-5 seconds on large repo - After:
git statustakes 0.3 seconds - That's a 10x improvement!
3. Aliases That Save Hours
Instead of typing long commands, use shortcuts:
git undo # Safely undo last commit
git amend # Quick amend without editing message
git gone # Delete local branches that were merged
git sync # Fetch all and pull with rebase
git recent # Show recently worked branches
git staged # Show staged changes
git unstage # Remove from staging
git wip # Quick work-in-progress commit
Time saved: ~30 minutes per day
4. Security Hardening
Built-in security features:
- Signed commits - Every commit is automatically signed
- Protocol blocking - No insecure git:// protocol
- Object verification - fsckObjects on transfer
- Secret protection - Global ignore for .env, keys, credentials
5. Better Diffs and Merges
Enhanced diff algorithm and merge conflict resolution:
[diff]
algorithm = histogram # Better than default Myers
colorMoved = plain # Highlight moved code
renames = true # Detect renames
[merge]
conflictstyle = zdiff3 # Show original + both changes
Result: Easier code reviews and conflict resolution
6. Conventional Commits
Built-in commit message template:
feat(scope): Add new feature
fix(scope): Fix bug
docs: Update documentation
Benefits:
- Consistent commit messages
- Automatic changelog generation
- Better team collaboration
7. Cross-Platform Support
Works seamlessly on macOS, Linux, and Windows:
- Automatic line ending normalization
- Platform-specific gitattributes
- Universal ignore patterns
Installation
5-minute setup:
# 1. Clone the repository
git clone https://github.com/yourusername/git-configuration.git
cd git-configuration
# 2. Copy configuration files
mkdir -p ~/.config/git
cp config ~/.config/git/config
cp commit-template.txt ~/.config/git/commit-template.txt
cp allowed_signers ~/.config/git/allowed_signers
cp attributes ~/.config/git/attributes
cp ignore ~/.config/git/ignore
# 3. Update with your info
# Edit ~/.config/git/config
# Replace "Your Name" and "your.email@example.com"
# 4. Set up SSH signing (if not already done)
# Add your SSH public key to GitHub/GitLab as a signing key
# 5. Test it
git config --list | grep user
Results
After using this configuration:
| Before | After |
|---|---|
| Setup time: 1+ hour | Setup time: 5 minutes |
| Commit signing: Complex GPG | Commit signing: Simple SSH |
| Git status: Slow | Git status: 10x faster |
| Team consistency: Variable | Team consistency: Standardized |
| Security: Manual | Security: Automated |
Get It Now
π¦ Repository: git-configuration
β Star it if you find it useful!
What's Next?
The repository includes:
- β Complete installation guide
- β SSH key generation tutorial
- β GitHub/GitLab setup instructions
- β Troubleshooting section
- β Team workflow recommendations
Your Turn
What git configurations have made your life easier? Share in the comments!
Tags: #git #productivity #opensource #devtools #tutorial #github #gitlab #ssh #performance #security
Top comments (0)