Hasty Briefsbeta

双语

Two Git ignore files nobody told me about

5 hours ago
  • Untracked files in Git repositories should never contain secrets to avoid accidental commits.
  • Git ignores files using three mechanisms: .gitignore (committed, shared), .git/info/exclude (per-clone, uncommitted), and global excludes (machine-wide, uncommitted).
  • The .git/info/exclude file is ideal for personal scratch files because it cannot be committed and remains private.
  • Global excludes (e.g., ~/.config/git/ignore) help manage editor and OS clutter without polluting project .gitignore files.
  • Committing patterns to .git/info/exclude requires manual appending; for linked worktrees, use 'git rev-parse --git-common-dir' to find the correct path.
  • Git automatically reads ~/.config/git/ignore if it exists, or a custom path can be set via 'git config --global core.excludesFile'.
  • Ignoring files via these methods immediately cleans 'git status' output without affecting tracked files.
  • Claude Code respects .git/info/exclude by default, hiding ignored files from @ autocomplete; this can be disabled in settings.