.gitconfig Generator
Generate a complete ~/.gitconfig file ready to drop onto any machine. Fill in your name, email, preferred editor and a few behavioural options — pull mode, line endings, prune — and the generator emits a clean INI-format config with well-commented sections. The optional aliases block adds a curated set of shortcuts every Git user should have.
How to use the .gitconfig Generator
Fill in your name and email — these appear in every commit you make and cannot be easily changed retroactively. Choose your editor: VS Code requires the --wait flag so Git blocks until you close the file; vim/nano/nvim are shell-blocking by default.
The default branch sets init.defaultBranch, which controls what Git names the first branch when you run git init. Set it to main to match GitHub/GitLab defaults. Pull mode determines what git pull does when there are divergent commits: merge creates a merge commit, rebase replays your commits on top (cleaner history), ff-only refuses to pull if a fast-forward is not possible (safest for shared branches).
Auto CRLF controls line-ending normalisation. Use input on macOS/Linux: it normalises to LF on commit but leaves files untouched on checkout. Use true on Windows to convert CRLF↔LF automatically. The aliases block adds short commands: git st, git lg (pretty log with graph), git last (show last commit), git unstage (reset HEAD). Copy or download the config, then run cp gitconfig ~/.gitconfig.
About ~/.gitconfig
Git reads configuration from three layers: the system config (/etc/gitconfig), the user config (~/.gitconfig or ~/.config/git/config), and the repository config (.git/config). Values in more-specific files override broader ones. The ~/.gitconfig file is the right place for personal identity, editor preferences, global aliases and default behaviour — anything that should apply to every repo on the machine.
The file uses INI format: section headers in square brackets ([user], [core]) followed by key = value pairs. Section names are case-insensitive. Git has evolved hundreds of config keys across versions; the ones generated here are the stable, widely-used subset that every developer benefits from.
A common mistake is setting a weak pull mode (pull.rebase = false) globally and then getting merge-commit noise in linear projects. Another is omitting fetch.prune, which lets stale remote-tracking branches (e.g. origin/feature/old-thing) accumulate indefinitely. Getting these right once in your global config saves friction on every future project.
Common use cases
- Provisioning a new machine — generate a config once, keep it in a dotfiles repo, and apply it to every new laptop or cloud VM in seconds.
- CI/CD environments — minimal gitconfigs for Docker images or CI runners that need a committer identity for automated commits.
- Onboarding new developers — share a team-standard config that sets the correct pull mode and line-ending policy to prevent cross-platform issues.
- Alias standardisation — ensure everyone on the team has the same
git lgpretty-log command so documentation and screencasts are reproducible. - Switching editors — regenerate to update the core.editor setting when moving from vim to VS Code.