Install the hg-git plugin on Ubuntu
hg-git is a mercurial plugin that is required by mercurial users to work with git repos. Below is a How-To to get it to work on Ubuntu or any similar linux distro e.g Pop OS.
Install pip3
sudo apt install python3-pip
Clone the hg-git repo (from the FOSS site) in your /tmp directory
cd /tmp
hg clone https://foss.heptapod.net/mercurial/hg-git
Install the cloned repo using pip3
pip3 install hg-git/
Enable the hg-git extension globally in the global .hgrc
vi ~/.hgrc
Add the following in the [extensions] block:
[extensions]
# uncomment the lines below to enable some popular extensions
# (see 'hg help extensions' for more info)
hgext.bookmarks =
hggit =
In your local mercurial repo, add a reference to a remote git repo, for example
vi .hg/hgrc
Add a reference to a git repo. Replace your_username and your_git_repo with your respective variables. I’m using bitbucket as an example below:
[paths]
default = git+ssh://git@bitbucket.org/your_username/your_git_repo.git
Fetch changes from a remote git repo
hg pull
To push a local mercurial repo to an online git repo, first add a bookmark
hg bookmark -r default master
Then you can push your changes
hg push
(Optional) To exclude viewing diffs from a certain file
hg diff --exclude yarn.lock