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:
This will take a few seconds, depending on how long your project's history is, and afterwards the `/tmp/authors`file will look something like this:
28
+
这会花费几秒钟,具体要看项目提交历史有多少,最终 `/tmp/authors`文件看起来会像这样:
29
29
30
30
[source]
31
31
----
@@ -37,10 +37,10 @@ Bob Jones <bob@company.com>
37
37
Joe Smith <joe@company.com>
38
38
----
39
39
40
-
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:
Hg-fast-export 通过向我们想要修改的行尾添加 `={new name and email address}`来修正这个问题,移除任何我们想要保留的用户名所在的行。
42
+
如果所有的用户名看起来都是正确的,那我们根本就不需要这个文件。
43
+
在本例中,我们会使文件看起来像这样:
44
44
45
45
[source]
46
46
----
@@ -50,7 +50,7 @@ bob jones <bob <AT> company <DOT> com>=Bob Jones <bob@company.com>
50
50
bob <bob@company.com>=Bob Jones <bob@company.com>
51
51
----
52
52
53
-
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