You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/09-git-and-other-scms/sections/import-hg.asc
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,31 @@
1
1
==== Mercurial
2
2
3
3
(((Mercurial)))(((Importing, from Mercurial)))
4
-
Since Mercurial and Git have fairly similar models for representing versions, and since Git is a bit more flexible, converting a repository from Mercurial to Git is fairly straightforward, using a tool called "hg-fast-export", which you'll need a copy of:
In this example, the same person (Bob) has created changesets under four different names, one of which actually looks correct, and one of which would be completely invalid for a Git commit.
41
-
Hg-fast-export lets us fix this by adding `={new name and email address}`at the end of every line we want to change, and removing the lines for any usernames that we want to leave alone.
42
-
If all the usernames look fine, we won't need this file at all.
43
-
In this example, we want our file to look like this:
The next step is to create our new Git repository, and run the export script:
53
+
下一步是创建一个新的 Git 仓库,然后运行导出脚本:
54
54
55
55
[source,console]
56
56
----
@@ -59,9 +59,9 @@ $ cd /tmp/converted
59
59
$ /tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors
60
60
----
61
61
62
-
The `-r`flag tells hg-fast-export where to find the Mercurial repository we want to convert, and the `-A`flag tells it where to find the author-mapping file.
63
-
The script parses Mercurial changesets and converts them into a script for Git's "fast-import" feature (which we'll discuss in detail a bit later on).
64
-
This takes a bit (though it's _much_ faster than it would be over the network), and the output is fairly verbose:
0 commit comments