Skip to main content

Overview

Git configuration controls how Git behaves. GitHub Desktop manages most Git configuration automatically, but understanding how it works helps you customize behavior when needed.

Global Config

Settings that apply to all repositories

Local Config

Repository-specific settings

User Identity

Name and email for commits

Behavior Settings

Line endings, merge strategies, and more

Configuration Levels

Git configuration exists at three levels:

System Level

Rarely used in GitHub Desktop workflows.

Global Level

This is where GitHub Desktop stores most settings.

Local Level

Repository-specific overrides.

Configuration Priority

When Git looks for a setting:
  1. Local (repository-specific) - Highest priority
  2. Global (user-level)
  3. System (machine-wide) - Lowest priority
Local settings override global, which override system.

Reading Configuration

GitHub Desktop provides functions to read Git configuration:
Usage Examples:
GitHub Desktop uses the -z flag with git config for null-terminated output, which safely handles values containing newlines.

Writing Configuration

Setting Values

Example:

Adding Multiple Values

Some settings can have multiple values:
Example:

Removing Values

Common Git Configuration

User Identity

GitHub Desktop sets these through File > Options > Git.

Default Branch

Configurable in GitHub Desktop preferences.

Line Endings

Use .gitattributes for fine-grained control over line endings instead of relying solely on core.autocrlf.

Editor

GitHub Desktop handles commit messages in the UI, so this mainly affects command-line Git.

Merge Tool

Credential Storage

GitHub Desktop uses OS credential storage automatically.

Safe Directories

Git 2.35.2+ requires repositories to be marked as “safe”:
This prevents Git from refusing to work in repositories owned by other users.

Getting Global Config Path

Returns the path to .gitconfig, creating it if it doesn’t exist.

Repository-Specific Configuration

Override global settings for a specific repository:

Via GitHub Desktop

1

Open Repository Settings

Right-click repository > Repository Settings
2

Configure Identity

Set name and email specific to this repository
3

Additional Settings

Use terminal for advanced configuration

Via Command Line

Common Configuration Scenarios

Work vs. Personal Repositories

GPG Signing

Proxy Settings

See Proxies for more details.

Large File Storage (LFS)

Viewing All Configuration

List All Settings

View Specific Section

Advanced Configuration

Aliases

Create shortcuts for common commands:

Diff and Merge Settings

Performance

Troubleshooting

If commits show the wrong author:
If configuration changes don’t work:
  • Check config priority (local > global > system)
  • Verify you’re setting the right level
  • Restart GitHub Desktop after changes
  • Check for typos in config names
If config commands fail:
  • Check file permissions on .gitconfig
  • Ensure Git is in PATH
  • Try running as administrator (Windows)
  • Check for file locks
To start fresh:

Best Practices

Use .gitattributes for line endings: Instead of relying on core.autocrlf, define line endings per file type in .gitattributes for consistent behavior across all contributors.
  1. Set Identity First
    • Always configure user.name and user.email before committing
    • Use work email for work repositories
    • Use personal email for open-source contributions
  2. Document Custom Configuration
    • Keep notes on non-standard settings
    • Share team configuration in repository README
    • Use consistent settings across team
  3. Use .gitattributes
    • Define line endings per file type
    • More reliable than core.autocrlf
    • Committed to repository (shared with team)
  4. Review Regularly
    • Audit config occasionally: git config --list
    • Remove obsolete settings
    • Update deprecated options
  5. Avoid System-Level Config
    • Use global or local instead
    • System config affects all users
    • Can cause confusion

Configuration Files

Example .gitconfig

Example .git/config (Local)