Git Configuration
Configure Git with your identity and preferences using git config.
Configuration Levels
Git has three configuration levels:
| Level | Flag | Location | Scope |
|---|---|---|---|
| System | --system | /etc/gitconfig | All users |
| Global | --global | ~/.gitconfig | Current user |
| Local | --local | .git/config | Current repo |
Essential Configuration
Set Your Identity
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
View Configuration
git config --list
git config user.name
Common Settings
Default Branch Name
git config --global init.defaultBranch main
Default Editor
git config --global core.editor "code --wait"
Line Endings
# Windows
git config --global core.autocrlf true
# Mac/Linux
git config --global core.autocrlf input
Aliases
Create shortcuts for common commands:
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
Now you can use:
git coinstead ofgit checkoutgit stinstead ofgit status
Configuration File Example
Your ~/.gitconfig might look like:
[user]
name = Developer
email = dev@example.com
[alias]
co = checkout
br = branch
[core]
editor = vim
Exercise: View Configuration
Run git config --list to see the current configuration:

