LinuxWindows

Where Is the Mercurial Config File?

Mercurial .hgrc and Mercurial.ini locations on Linux and Windows with repo overrides.

Last updated

Mercurial reads INI-style config from user files with per-repository overrides in .hg\hgrc. Username, extensions, merge tools and auth live in the user file.

Config cascades from system to user to repo, with each level winning. Keep secrets in the user file and shareable hooks in the repo one.

Where Mercurial stores this, by platform

Linux
~/.hgrc

Main user config with ui.username, extensions and merge tools. Newer installs also read ~/.config/hg/hgrc. Repo overrides live at .hg/hgrc inside each clone. Never commit the repo hgrc blindly since hooks there execute on every operation.

Windows
%USERPROFILE%\Mercurial.ini

Same user config role as .hgrc on Linux, with %USERPROFILE%\.hgrc as an alternate. Per-repo settings sit in .hg\hgrc as usual.

Frequently asked questions

How do I set my Mercurial username?

Add username under [ui] in the user config above. Commits stamp it until a repo hgrc overrides.

Where do Mercurial extensions enable?

Under [extensions] in the same user files. Repo-level enables go in .hg/hgrc for settings the whole team shares.

Notice an outdated path? Let us know.