【问题标题】:Adding symlink to repository on windows将符号链接添加到 Windows 上的存储库
【发布时间】:2016-03-19 10:58:30
【问题描述】:

Mercurial 允许在存储库中对符号链接进行版本控制。在 unix 上,它们在结帐时创建为符号链接,而在 Windows 上则不支持符号链接。

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

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

我想这将涉及创建“特殊文本”文件,然后以某种方式告诉 mercurial 将其视为符号链接。可能使用类似于this workaround for setting the executable bit 的解决方法。

【问题讨论】:

    标签: mercurial tortoisehg


    【解决方案1】:

    我没有在 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 替换为应该是符号链接的文件的名称,将other/file 替换为要链接到的文件的名称。

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

    【讨论】:

    • 感谢您抽出宝贵时间试用!
    猜你喜欢
    • 2018-03-12
    • 1970-01-01
    • 2018-06-20
    • 2010-11-29
    • 2014-11-22
    • 1970-01-01
    • 1970-01-01
    • 2019-01-11
    • 2022-12-09
    相关资源
    最近更新 更多