hg-init
Create a new Mercurial repository
TLDR
Initialize a new repository in the current directory
Initialize a new repository in the specified directory
SYNOPSIS
hg init [-d <path>] [-R <repo>] [--mq] [--insecure] [--traceback] [--config <SECTION.OPTION>=<VALUE>] [-h] [DEST]
PARAMETERS
-R, --repository <repo>
Repository root directory before URI discovery or clone.
-d, --directory <path>
Create repository in the given directory (DEPRECATED).
--mq
Enable Mercurial Queues in the repository (DEPRECATED).
--insecure
Do not verify server certificate (DEPRECATED).
--traceback
Print traceback on unexpected errors if stderr is a TTY.
--config <SECTION.OPTION>=<VALUE>
Set or override config option for the repository.
-h, --help
Show help message and exit.
DESCRIPTION
The hg init command creates a new Mercurial (Hg) repository in the specified directory. Mercurial is a distributed version control system designed for efficient handling of large projects and binary files.
If no destination directory is provided, it initializes the repository in the current working directory. The command sets up essential repository files and directories, including .hg/store for metadata, .hg/requires for format requirements, and .hg/wlock for write locks.
Upon successful initialization, the repository is ready for hg add, hg commit, and other operations. It supports extensions like MQ (Mercurial Queues) via deprecated flags. This command is fundamental for starting version-controlled projects, enabling cloning, pushing, and pulling changes across distributed setups.
Mercurial repositories are self-contained, allowing offline work and peer-to-peer collaboration without a central server.
CAVEATS
Many options like -d, --mq, --insecure are deprecated in modern Mercurial versions (4.0+). Use hg config for settings instead. Running in an existing repo may fail or overwrite files.
EXAMPLE USAGE
hg init myproject creates repo in myproject/.
cd myproject && hg init . initializes current directory.
POST-INIT STEPS
Run hg verify to check integrity. Add .hgignore for file patterns to ignore.
HISTORY
Mercurial was created by Matt Mackall in 2005 as a free alternative to Git, with hg init available since version 0.9.1. It evolved with repository formats (e.g., revlog v1 in 0.1, fncache in 3.1), deprecating legacy options for better security and performance.


