Initializing a Mercurial Repository (with examples)
1: Initialize a new repository in the current directory
The initial use case for the hg init
command is to create a new Mercurial repository in the current working directory. This is done by simply executing the hg init
command without any arguments.
hg init
Motivation for using this example:
- You want to start tracking changes in a project and create a repository from scratch in the current directory.
Explanation for the argument:
- No argument is required for this use case.
Example output:
$ hg init
initialized empty repository in /path/to/current/directory/.hg/
2: Initialize a new repository in the specified directory
The hg init
command also allows you to create a new Mercurial repository in a specific directory by providing the path to that directory as an argument.
hg init path/to/directory
Motivation for using this example:
- You want to initialize a new repository in a specific directory that is different from the current working directory.
Explanation for the argument:
path/to/directory
: The path to the directory where you want to create the repository. Replace this with the actual path of the directory.
Example output:
$ hg init path/to/directory
initialized empty repository in /path/to/directory/.hg/