Skip to main content

132. Global Git Configuration

Status: Accepted Date: 2025-07-06

Context

We need to ensure that Git behaves in a consistent, predictable way on all servers, especially for automated processes or when a user first logs in before their personal dotfiles have been applied. Key configuration settings, like the default editor or pull behavior, can cause scripts to fail or confuse users if they are not set to a sensible default.

We do not want to configure user-specific settings like user.name or user.email at the system level, as these are personal and will be managed by the user's own dotfiles.

Decision

The 01_common Ansible role will be responsible for applying a minimal, system-wide Git configuration.

This will be done using Ansible's git_config module with the scope set to global. The configuration will be kept minimal and focused on behavior, not identity. The chosen settings are:

  • core.editor: vim (ensuring that any Git command that opens an editor will succeed, as Vim is part of our essential packages).
  • pull.rebase: false (setting a safe, non-destructive default for the pull strategy).

User-specific settings (user.name, user.email, aliases, etc.) are explicitly NOT configured here. They will be layered on top of this global configuration by the user's personal dotfiles, deployed via chezmoi.

Consequences

Positive:

  • Predictable Behavior: Guarantees that Git has a safe, predictable default behavior on all machines, which is important for both interactive use and automation.
  • Prevents Failures: Setting a default editor prevents Git commands from failing in an interactive session if GIT_EDITOR is not set.
  • Clear Separation of Concerns: A clear line is drawn between system-level behavioral configuration (managed by Ansible) and user-level identity configuration (managed by dotfiles).

Negative:

  • Opinionated Defaults: The chosen defaults (e.g., pull.rebase=false) are opinionated. A user who prefers a different default will have to override it in their personal configuration.

Mitigation:

  • Safe and Sensible Opinions: The chosen defaults are widely considered to be safe and sensible for a baseline. A merge-based pull is less destructive than a rebase-based one, making it a safer default.
  • Easy to Override: This is the intended workflow. The global configuration provides the baseline, and users are expected to override it with their personal preferences in their own ~/.gitconfig file, which is exactly what our chezmoi integration enables.