在 windows 上将符号链接添加到存储库

Adding symlink to repository on windows

Mercurial 允许版本库中的符号链接。在 unix 上,它们在结帐时创建为符号链接,而在 windows 上不支持符号链接。

相反,Mercurial 显然会为每个符号链接创建一个 "special" 文本文件,其内容是符号链接的目标。通过在 windows 机器上修改此文本文件的内容,可以更改 "symlink" 的目标。 (See this SO answer.)

是否可以在 Windows 机器上的 Mercurial 存储库中创建新的符号链接?

我想这将涉及创建 "special text" 文件,然后以某种方式告诉 mercurial 将其视为符号链接。可能使用类似于 this workaround for setting the executable bit.

的解决方法

我没有在 Windows 上安装 Mercurial 来尝试这个,但是对以下文件使用 hg import(可能是 hg import --no-commit)似乎在 OS X 并且应该在 Windows:

上工作
diff --git a/link b/link
new file mode 120000
--- /dev/null
+++ b/link
@@ -0,0 +1,1 @@
+other/file
\ No newline at end of file

link 替换为应该是 symlink 的文件名,将 other/file 替换为要 link 的文件名.

注意最后一行很重要;它可以防止在路径末尾添加换行符。