Please follow the excellent description on the Git documentation
Here are some personal additions.
My setup is:
I issued these commands:
# Install mercurial if not present and prepare a working directory.
sudo yum install -y mercurial
hg --version
mkdir hg2git-myrep
cd hg2git-myrep
# Get fast-export
git clone https://github.com/frej/fast-export.git
git checkout tags/v180317
# Clone mercurial repository and extract authors
# Use the --insecure switch if you are cloning from an internal
# server with self-signed certificates
hg clone https://<url-to-my-hg-repository>/ tmp/hg-my-repository
cd tmp/hg-my-repository
hg log | grep user: | sort | uniq | sed 's/user: *//' > ../authors
cd ..
# Now sanitize the author list
vi authors
# Create and init git repository and import mercurial repo
mkdir git-my-repository
cd git-myrepository
git init
../../fast-export/hg-fast-export.sh -r ../hg-oltptest -A ../authors
# Check if have imports
git shortlog -sn
git branch
Now we have the repository with the complete history in git.
Next steps can be to (re-)organize the branches to match your Git’s policy and to add a remote and upload the repository to your project’s Git server.