Skip to content

Commit b8dc145

Browse files
committed
Merge pull request #183 from networm/09-git-and-other-scms_import-tfs
Translate 09-git-and-other-scms import-tfs
2 parents 94dd6e3 + e6d62f3 commit b8dc145

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

book/09-git-and-other-scms/sections/import-tfs.asc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,59 @@
22
==== TFS
33

44
(((TFS)))(((Importing, from TFS)))
5-
If your team is converting their source control from TFVC to Git, you'll want the highest-fidelity conversion you can get.
6-
This means that, while we covered both git-tfs and git-tf for the interop section, we'll only be covering git-tfs for this part, because git-tfs supports branches, and this is prohibitively difficult using git-tf.
5+
如果你的团队正在将他们的源代码管理从 TFVC 转换为 Git,你们会想要最高程度的无损转换。
6+
这意味着,虽然我们在之前的交互章节介绍了 git-tfs git-tf 两种工具,但是我们在本部分只能介绍 git-tfs,因为 git-tfs 支持分支,而使用 git-tf 代价太大。
77

88
[NOTE]
99
====
10-
This is a one-way conversion.
11-
The resulting Git repository won't be able to connect with the original TFVC project.
10+
这是一个单向转换。
11+
这意味着 Git 仓库无法连接到原始的 TFVC 项目。
1212
====
1313

14-
The first thing to do is map usernames.
15-
TFVC is fairly liberal with what goes into the author field for changesets, but Git wants a human-readable name and email address.
16-
You can get this information from the `tf` command-line client, like so:
14+
第一件事是映射用户名。
15+
TFVC 对待变更集作者字段的内容相当宽容,但是 Git 需要人类可读的名字与邮箱地址。
16+
可以通过 `tf` 命令行客户端来获取这个信息,像这样:
1717

1818
[source,powershell]
1919
----
2020
PS> tf history $/myproject -recursive > AUTHORS_TMP
2121
----
2222

23-
This grabs all of the changesets in the history of the project and put it in the AUTHORS_TMP file that we will process to extract the data of the 'User' column (the 2nd one).
24-
Open the file and find at which characters start and end the column and replace, in the following command-line, the parameters `11-20` of the `cut` command with the ones found:
23+
这会将历史中的所有变更集抓取下来并放到 AUTHORS_TMP 文件中,然后我们将会将 `User` 列(第二个)取出来。
24+
打开文件找到列开始与结束的字符并替换,在下面的命令行中,`cut` 命令的参数 `11-20` 就是我们找到的:
2525

2626
[source,powershell]
2727
----
2828
PS> cat AUTHORS_TMP | cut -b 11-20 | tail -n+3 | uniq | sort > AUTHORS
2929
----
3030

31-
The `cut` command keeps only the characters between 11 and 20 from each line.
32-
The `tail` command skips the first two lines, which are field headers and ASCII-art underlines.
33-
The result of all of this is piped to `uniq` to eliminate duplicates, and saved to a file named `AUTHORS`.
34-
The next step is manual; in order for git-tfs to make effective use of this file, each line must be in this format:
31+
`cut` 命令只会保留每行中第 11 个到第 22 个字符。
32+
`tail` 命令会跳过前两行,就是字段表头与 ASCII 风格的下划线。
33+
所有这些的结果通过管道送到 `uniq` 来去除重复,然后保存到 `AUTOHRS` 文件中。
34+
下一步是手动的;为了让 git-tfs 有效地使用这个文件,每一行必须是这种格式:
3535

3636
[source,text]
3737
----
3838
DOMAIN\username = User Name <[email protected]>
3939
----
4040

41-
The portion on the left is the ``User'' field from TFVC, and the portion on the right side of the equals sign is the user name that will be used for Git commits.
41+
左边的部分是 TFVC 中的 ``User'' 字段,等号右边的部分是将被用作 Git 提交的用户名。
4242

43-
Once you have this file, the next thing to do is make a full clone of the TFVC project you're interested in:
43+
一旦有了这个文件,下一件事就是生成一个你需要的 TFVC 项目的完整克隆:
4444

4545
[source,powershell]
4646
----
4747
PS> git tfs clone --with-branches --authors=AUTHORS https://username.visualstudio.com/DefaultCollection $/project/Trunk project_git
4848
----
4949

50-
Next you'll want to clean the `git-tfs-id` sections from the bottom of the commit messages.
51-
The following command will do that:
50+
接下来要从提交信息底部清理 `git-tfs-id` 区块。
51+
下面的命令会完成这个任务:
5252

5353
[source,powershell]
5454
----
5555
PS> git filter-branch -f --msg-filter 'sed "s/^git-tfs-id:.*$//g"' -- --all
5656
----
5757

58-
That uses the `sed` command from the Git-bash environment to replace any line starting with ``git-tfs-id:'' with emptiness, which Git will then ignore.
58+
那会使用 Git 终端环境中的 `sed` 命令来将所有以 ``git-tfs-id:'' 开头的行替换为 Git 会忽略的空白。
5959

60-
Once that's all done, you're ready to add a new remote, push all your branches up, and have your team start working from Git.
60+
全部完成后,你就已经准备好去增加一个新的远程仓库,推送你所有的分支上去,然后你的团队就可以开始用 Git 工作了。

0 commit comments

Comments
 (0)