I don\'t have a huge experience with Mercurial, I\'m mostly a Git guy.
I would love to mirror a specific Mercurial folder/file in a git Repository. What I\'m actuall
Hg-Git can be used to convert a Mercurial repository to Git. You can use a local repository or a remote repository accessed via SSH, HTTP or HTTPS.
Install Hg-Git.
On Windows, TortoiseHg comes with Hg-Git, though you need to enable it via the setting tool (in extensions section)
or manually in ~/mercurial.ini
[extensions]
hggit =
Use the following commands to convert the repository:
$ mkdir git-repo; cd git-repo; git init; cd ..
$ cd hg-repo
$ hg bookmarks hg
$ hg push ../git-repo
The hg
bookmark is necessary to prevent problems as otherwise hg-git pushes to the currently checked out branch confusing Git. This will create a branch named hg
in the Git repository. To get the changes in master use the following commands (only necessary in the first run, later just use git merge
or rebase
):
$ cd git-repo
$ git checkout -b master hg
On Linux or anything with bash/sh
or similar, or python
, try with fast export:
cd
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
git checkout HEAD
If you're using github.com, they appear to have an import feature that lets you simply type in the URL of your hg project.
First create a new repository and then on the new repository's landing page scroll to the bottom and click the "Import code" button.
Then type the URL of your previous repository and hit "Begin import".
Then GitHub takes care of the rest!
Note that GitHub will ask you for your credentials for the old repository if it needs them.
Ooh! I found the official guide
On Windows can be a bit tricky. After enabling the right plugins in mercurial( hggit
), the TortoiseHG can also be used.
Using the console :
% hg bookmarks hg
% hg push <relative path to>/<git-repo>
https://github.com/kilork/hg-git-fast-import
Another utility with the following features:
You may download binary for you platform and put somewhere in path or install with cargo
(require rust
to be installed):
cargo install hg-git-fast-import
Then usage is like this:
hg-git-fast-import single /path/to/source_hg /path/to/target_git
It does not need Python
and Mercurial
to be installed. Advanced configuration allows to replace authors or branches, make branches prefixed and more.
md new-repo && cd new-repo
git init --bare .git
cd ..\old-mercurial-repo
hg bookmark -r default master
hg push ..\new-repo
cd ..\new-repo
git config --bool core.bare false
Open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Install Ubuntu 16.04 LTS from Microsoft Store
install mercurial
sudo -s
apt-get update
apt install mercurial
get fast-export v180317 (at the moment versions after 180317 does not work correctly)
cd /mnt/c/path_to_work_folder
git clone https://github.com/frej/fast-export.git
cd fast-export
git checkout tags/v180317
cd ..
convert repository
git init new-repo && cd new-repo
git config core.ignoreCase false && git config core.quotepath off
../fast-export/hg-fast-export.sh -r ../path_to_mercurial_repo/ --fe cp1251
git checkout master
encoding options:
-f
encoding, like -f cp1251
--fe
file name encoding like --fe cp1251