Skip to main content

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.

# Convert LF to CRLF on checkout, CRLF to LF on commit
git config --global core.autocrlf true

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