dotfiles

Git Configuration Reference

Overview

Git configuration for this dotfiles setup, providing aliases, tools integration, and security settings.

Synopsis

~/.gitconfig                 # Main configuration (symlinked)
~/.config/git/ignore        # Global ignore patterns
~/.gitmessage              # Commit message template

Configuration Sections

[user]

Identifies you as the author of commits.

Fields:

Example:

[user]
    name = Your Name
    email = your.email@example.com
    signingKey = E8404D8E8DAB59CD1E5255BD56BCDEBC6448A091

[core]

Core Git behavior settings.

Fields:

autocrlf

Type: true | false | input
Default: false
Current: input

Controls line ending conversion. input converts CRLF to LF on commit but not on checkout (recommended for macOS/Linux).

safecrlf

Type: true | false | warn
Default: false
Current: true

Prevents commits with mixed line endings when enabled.

editor

Type: string
Current: code --new-window --wait

Default editor for commit messages and interactive operations.

excludesfile

Type: path
Current: ~/.gitignore_global

Path to global gitignore file.

pager

Type: string
Current: bat

Program used to page through output (logs, diffs, etc.).

[alias]

Custom shortcuts for Git commands.

Available Aliases:

Alias Expands To Description
co checkout Switch branches or restore files
ci commit Record changes to repository
st status Show working tree status
br branch List, create, or delete branches
hist log --pretty=format:"%h %ad \| %s%d [%an]" --graph --date=short Graphical history view
type cat-file -t Show object type
dump cat-file -p Show object content

[diff] & [difftool]

Diff viewing configuration.

Fields:

VSCode Difftool Config:

[difftool "code"]
    cmd = code --wait --new-window --diff $LOCAL $REMOTE

[merge] & [mergetool]

Merge conflict resolution settings.

Fields:

VSCode Mergetool Config:

[mergetool "code"]
    cmd = code --wait --new-window --merge $REMOTE $LOCAL $BASE $MERGED

[push]

Push behavior configuration.

Fields:

[pull]

Pull behavior settings.

Fields:

[filter]

Content filters for large files and media.

LFS Filter:

[filter "lfs"]
    smudge = git-lfs smudge -- %f
    required = true
    clean = git-lfs clean -- %f
    process = git-lfs filter-process

[color]

Output colorization settings.

Fields:

[branch]

Branch behavior configuration.

Fields:

[rerere]

Reuse recorded resolution for merge conflicts.

Fields:

[commit]

Commit behavior settings.

Fields:

[gpg]

GPG signing configuration.

Fields:

Global Ignore Patterns

Located at ~/.config/git/ignore:

# macOS
*.DS_Store
.AppleDouble
.LSOverride
Icon
._*

# Thumbnails
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories on AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Claude local settings
**/.claude/settings.local.json

# Zsh compiled files
*.zwc
*.zwc.*

Examples

Basic Usage

# Check current configuration
git config --list

# Get specific setting
git config user.name

# Set configuration value
git config --global core.editor "vim"

Using Aliases

# Instead of: git checkout feature-branch
git co feature-branch

# Instead of: git status
git st

# View pretty history
git hist

External Tools

# Open diff in VSCode
git difftool HEAD~1

# Resolve merge conflicts in VSCode
git mergetool

Environment Variables

Git respects these environment variables:

Variable Purpose Example
GIT_EDITOR Override core.editor export GIT_EDITOR=vim
GIT_PAGER Override core.pager export GIT_PAGER=less
GIT_AUTHOR_NAME Override user.name export GIT_AUTHOR_NAME="Bot"
GIT_AUTHOR_EMAIL Override user.email export GIT_AUTHOR_EMAIL="bot@example.com"

Security Considerations

  1. GPG Signing: Commits are signed with the configured GPG key
  2. Credentials: Stored in system keychain via credential helpers
  3. Tokens: GitHub tokens stored in macOS keychain (see [ghi] section)
  4. SSH: Prefer SSH URLs over HTTPS for better security

See Also