Git Configuration
This guide covers essential Git configuration for your development environment.
Set Your Identity
Git uses your name and email to identify you as the author of commits.
# Set your name
git config --global user.name "Your Name"
# Set your email (use your work email for work projects)
git config --global user.email "your.email@example.com"
Verify Your Configuration
# View all global settings
git config --global --list
# Check specific values
git config --get user.name
git config --get user.email
Default Branch Name
Set main as the default branch name for new repositories:
git config --global init.defaultBranch main
Line Endings
Configure Git to handle line endings consistently across operating systems.
- Windows
- macOS
- Linux
# Convert LF to CRLF on checkout, CRLF to LF on commit
git config --global core.autocrlf true
# Convert CRLF to LF on commit
git config --global core.autocrlf input
# Convert CRLF to LF on commit
git config --global core.autocrlf input
Useful Aliases
Add convenient shortcuts for common commands:
# Short status
git config --global alias.st status
# Pretty log
git config --global alias.lg "log --oneline --graph --decorate"
# Amend without editing message
git config --global alias.amend "commit --amend --no-edit"
Editor Configuration
Set your preferred text editor for commit messages:
# VS Code
git config --global core.editor "code --wait"
# Vim
git config --global core.editor "vim"
# Nano
git config --global core.editor "nano"
Pull Behavior
Configure how git pull handles divergent branches:
# Rebase local changes on top of remote (recommended)
git config --global pull.rebase true
# Or merge (creates merge commits)
git config --global pull.rebase false
Related
- SSH Keys - Set up SSH authentication
- Commit Signing - Sign your commits
- GitHub Setup - GitHub-specific configuration