如何在不丢失分支的情况下将 mercurial 存储库转换为 git 存储库?
How to convert mercurial repository to git repository without losing branches?
我想将 mercurial repo 转换为 git repo。实际上我做了但我没有看到分支机构。转换 repo 后,我只能看到一个分支(作为主分支)我看不到任何其他分支,但我可以看到历史(所有更改)是正确的。单击任何提交时,我可以看到这样的信息:
Date: 19 Nisan 2019 Cuma 15:14:37
Committer: sevgi.cakmak
Change dialog header
--HG--
branch : sevgi-2.0.0
但我在左侧看不到 sevgi-2.0.0 分支(我正在使用 sourcetree)。
我的步数:
mercurial.ini 文件:
[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
(也试过这样:hg bookmark -r default master
)
然后我从 cmd
开始处理这一行
hg gexport --debug //this line converting all revision
完成这一行后我的输出如下:
converting revision a318482e0769e2fceb13a1545cb477d60a00b434
converting revision e444655d161131f9ed1676f6c175813097fd18g8
converting revision 0ab06d22eaf4ff4ecb96caba343fdcc3a85e367k
converting revision 8a4e7f4defb0b04e76e67a825bedf746fe4f3fc5 ......etc
然后我在这条线 git config --bool core.bare false
工作。
毕竟我确实打开了 .git 下的分支文件夹,而这个旧的是空的。我想在我的仓库中看到分支。
参考:https://helgeklein.com/blog/2015/06/converting-mercurial-repositories-to-git-on-windows/
我也尝试过快速导出,但没有成功。
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 called
release_6_maintenance_bookmark
. hg-git will then strip off the
_bookmark
suffix from this bookmark name, and create a git branch
called release_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 the
release_6_maintenance
branch are checked into git, these will be
placed into the release_6_maintenance_bookmark
bookmark on hg. But
if a new branch called release_7_maintenance
were pulled over to hg,
and there was not a release_7_maintenance
named branch already, the
bookmark will be named release_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.
我想将 mercurial repo 转换为 git repo。实际上我做了但我没有看到分支机构。转换 repo 后,我只能看到一个分支(作为主分支)我看不到任何其他分支,但我可以看到历史(所有更改)是正确的。单击任何提交时,我可以看到这样的信息:
Date: 19 Nisan 2019 Cuma 15:14:37
Committer: sevgi.cakmak
Change dialog header
--HG--
branch : sevgi-2.0.0
但我在左侧看不到 sevgi-2.0.0 分支(我正在使用 sourcetree)。
我的步数:
mercurial.ini 文件:
[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
(也试过这样:hg bookmark -r default master
)
然后我从 cmd
hg gexport --debug //this line converting all revision
完成这一行后我的输出如下:
converting revision a318482e0769e2fceb13a1545cb477d60a00b434
converting revision e444655d161131f9ed1676f6c175813097fd18g8
converting revision 0ab06d22eaf4ff4ecb96caba343fdcc3a85e367k
converting revision 8a4e7f4defb0b04e76e67a825bedf746fe4f3fc5 ......etc
然后我在这条线 git config --bool core.bare false
工作。
毕竟我确实打开了 .git 下的分支文件夹,而这个旧的是空的。我想在我的仓库中看到分支。
参考:https://helgeklein.com/blog/2015/06/converting-mercurial-repositories-to-git-on-windows/
我也尝试过快速导出,但没有成功。
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.