Git — Configuration
Configuration Levels
| Level | File | Command |
|---|---|---|
| System | /etc/gitconfig | --system |
| Global | ~/.gitconfig | --global |
| Local | .git/config | --local |
Essential Settings
# User information
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
# Default branch name
git config --global init.defaultBranch main
# Editor
git config --global core.editor "code --wait"
git config --global core.editor "vim"
# Line endings
git config --global core.autocrlf true # Windows
git config --global core.autocrlf input # macOS/Linux
View Configuration
git config --list
git config user.name
git config --global --list
Aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.lg "log --oneline --graph"
SSH Keys
# Generate key
ssh-keygen -t ed25519 -C "your@email.com"
# Add to SSH agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Copy public key
cat ~/.ssh/id_ed25519.pub
Mini Practice
- Set user information
- Configure editor
- Create aliases
- Set up SSH keys
Up Next
Continue with Create Repository — creating repositories.
Related Topics
Frequently Asked Questions about Configuration
What is Configuration in Git?
Configuration is a fundamental concept in Git. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Configuration?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Configuration.
Why is Configuration important in Git?
Configuration is essential for Git development. Understanding this concept will help you write better code and solve real-world problems more effectively.