问题
I want to convert mercurial repo to git repo. Actually I did but I didnt see branches. After I converted repo I can see just one branch(as master) I cannot see any other branches but I can see history(all changes) as right. when clicked any commits I can see like this information :
Date: 19 Nisan 2019 Cuma 15:14:37
Committer: sevgi.cakmak
Change dialog header
--HG--
branch : sevgi-2.0.0
but I cannot see sevgi-2.0.0 branch on the left side (I am using sourcetree).
My steps:
mercurial.ini file:
[extensions]
strip =
histedit =
rebase =
hggit = C:\Users\sevgi.cakmak\Desktop\hg-git\hggit
hgext.bookmarks =
[git]
intree = True
hg bookmark -r 2.0.0 master
(also tried like this: hg bookmark -r default master
)
and then I worked this line from cmd
hg gexport --debug //this line converting all revision
after worked this line my output like this:
converting revision a318482e0769e2fceb13a1545cb477d60a00b434
converting revision e444655d161131f9ed1676f6c175813097fd18g8
converting revision 0ab06d22eaf4ff4ecb96caba343fdcc3a85e367k
converting revision 8a4e7f4defb0b04e76e67a825bedf746fe4f3fc5 ......etc
and then I worked this line git config --bool core.bare false
.
After all I did open branches folder under the .git and this older is empty. I want to see branches on my repo.
reference: https://helgeklein.com/blog/2015/06/converting-mercurial-repositories-to-git-on-windows/
also I tried fast-export but didnt work.
回答1:
From docs section Usage:
Hg-Git pushes your bookmarks up to the Git server as branches and will pull Git branches down and set them up as bookmarks.
...
Configuration
...
git.branch_bookmark_suffix
hg-git does not convert between Mercurial named branches and git branches as the two are conceptually different; instead, it uses Mercurial bookmarks to represent the concept of a git branch. Therefore, when translating an hg repo over to git, you typically need to create bookmarks to mirror all the named branches that you'd like to see transferred over to git. The major caveat with this is that you can't use the same name for your bookmark as that of the named branch, and furthermore there's no feasible way to rename a branch in Mercurial.
For the use case where one would like to transfer an hg repo over to git, and maintain the same named branches as are present on the hg side, the
branch_bookmark_suffix
might be all that's needed. This presents a string "suffix" that will be recognized on each bookmark name, and stripped off as the bookmark is translated to a git branch:[git] branch_bookmark_suffix=_bookmark
Above, if an hg repo had a named branch called
release_6_maintenance
, you could then link it to a bookmark calledrelease_6_maintenance_bookmark
. hg-git will then strip off the_bookmark
suffix from this bookmark name, and create a git branch calledrelease_6_maintenance
. When pulling back from git to hg, the_bookmark
suffix is then applied back, if and only if an hg named branch of that name exists. E.g., when changes to therelease_6_maintenance
branch are checked into git, these will be placed into therelease_6_maintenance_bookmark
bookmark on hg. But if a new branch calledrelease_7_maintenance
were pulled over to hg, and there was not arelease_7_maintenance
named branch already, the bookmark will be namedrelease_7_maintenance
with no usage of the suffix.The
branch_bookmark_suffix
option is, like the authors option, intended for migrating legacy hg named branches. Going forward, an hg repo that is to be linked with a git repo should only use bookmarks for named branching.
来源:https://stackoverflow.com/questions/56129896/how-to-convert-mercurial-repository-to-git-repository-without-losing-branches