Hello! There is a big problem with moving to git. For some reason, only one branch moves, and there are plenty of them ... I use TortoiseHg with the hggit plugin. In hgrc, I only change the path. Please help in this matter.
1 answer
For a penguin, it's better to do this:
There is a tool hg-fast-export .
It can be found here:
git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export Need to get a mercurial turnip:
hg clone <remote repo URL> /tmp/hg-repo Next you need to create an author matching file.
cd /tmp/hg-repo hg log | grep user: | sort | uniq | sed 's/user: *//' > ../authors In / tmp / authors there will be approximately the following content:
bob bob@localhost bob <bob@company.com> bob jones <bob <AT> company <DOT> com> Bob Jones <bob@company.com> Joe Smith <joe@company.com> In the example above, the same person (Bob) made changes under five different names, only one of which is correct, and one does not at all correspond to the Git format. hg-fast-export allows you to quickly remedy the situation by adding = {new name and email address} to each line we want to change; To leave the name as it is, simply delete the lines. If all the names look good, this file is not required at all. In our example, we want the data to look like this:
bob=Bob Jones <bob@company.com> bob@localhost=Bob Jones <bob@company.com> bob jones <bob <AT> company <DOT> com>=Bob Jones <bob@company.com> bob <bob@company.com>=Bob Jones <bob@company.com> Then you need to create a Git repository and run the export:
git init /tmp/converted cd /tmp/converted /tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors The -r flag indicates the Mercurial repository to be converted, and the -A flag specifies a file with correspondences between authors. The script goes over the Mercurial change sets and converts them into a fast-import script in Git. And send the change to the turnip gita:
git remote add origin git@my-git-server:myrepository.git git push origin --all For Windows, there are almost only a few other commands:
cd c:\projects hg clone <remote repo URL> hg-repo git init converted git clone http://repo.or.cz/r/fast-export.git Edit c: \ projects \ fast-export \ hg-fast-export.py . The beginning of this script needs to be replaced with this:
#!/usr/bin/env python # Copyright (c) 2007, 2008 Rocco Rutte <pdmef@gmx.net> and others. # License: MIT <http://www.opensource.org/licenses/mit-license.php> import sys # import mercurial libraries from zip: sys.path.append(r'C:\Program Files (x86)\Mercurial\library.zip') from mercurial import node from hg2git import setup_repo, fixup_user, get_branch, get_changeset from hg2git import load_cache, save_cache, get_git_sha1, set_default_branch, set_origin_name from optparse import OptionParser import re import os Copy fast-export to converted ignoring the .git folder. Next: cd converted and create a file here.axtxt by analogy from the linux version.
And hg-fast-export.sh -rc:\projects\hg-repo -A authors.txt Done. Then you can upload git turnips to the server.
- Ilya thank you very much. Everything really passed through hg-fast-export. The only thing was to apply the --force parameter when exporting. And so everything fell off and even gathered after that. Special thanks for the well-prepared answer, everything is very beautiful and to the point. - Glory