gpt4 book ai didi

windows - 当我在 Windows 上克隆带有符号链接(symbolic link)的存储库时会发生什么?

转载 作者:IT王子 更新时间:2023-10-29 00:44:12 25 4
gpt4 key购买 nike

关于在 Windows 上添加对符号链接(symbolic link)的支持存在很多问题。但是,当我克隆 a repository with symlinks 时实际发生了什么在 Windows 上?

最佳答案

version 1.5.3 native Git 客户端 git clonegit init 将探测目标文件系统以获得符号链接(symbolic link)支持,并为 core.symlinks 设置本地存储库配置相应地,即对于 FAT 或 NTFS 为 false这使得符号链接(symbolic link)被创建和提交,例如在 Linux 下显示为包含 Windows 下链接文本的纯文本文件(有关详细信息,请参阅 git config documentation on core.symlinks)。

Git for Windows version 2.10.2安装程序有 an explicit option to enable symbolic link support .

在旧版本的 Windows 版 Git 中,您可以手动将 core.symlinks 设置为 true,这使 Git 能够在以下约束下创建符号链接(symbolic link):

  • 符号链接(symbolic link)仅适用于 Windows Vista 及更高版本。
  • 符号链接(symbolic link)仅适用于 NTFS,不适用于 FAT。
  • 您需要是管理员和/或拥有 SeCreateSymbolicLinkPrivilege 权限。
  • 默认情况下禁用远程文件系统上的符号链接(symbolic link)。
  • Windows 的符号链接(symbolic link)是键入的。
  • 许多程序不理解符号链接(symbolic link)(包括旧版本的 Windows 资源管理器)。

更多details在 Git for Windows wiki 中可用。

在旧版本的 Windows 版 Git 中,在克隆和重置工作树后手动将 core.symlinks 手动设置为 true,您会收到类似以下的错误消息

$ git reset --hard HEAD
error: unable to create symlink directory (Function not implemented)
error: unable to create symlink linux-links/this_is_a_symbolic_link_to_file (Function not implemented)
fatal: Could not reset index file to revision 'HEAD'.

作为旁注,JGit 客户端直到其版本 3.3 才探测目标文件系统以获得符号链接(symbolic link)支持,因此 core.symlinks 设置回落到任何系统/全局 Git 配置曾是。以 version 3.3 开头JGit 探测符号链接(symbolic link)支持,但似乎过于保守,设置 core.symlinks = false in some cases where symlinks would be in fact supported .

您可以 checkout https://github.com/sschuberth/git-playground其中包含一堆在 Linux 上创建的用于测试的链接。

关于windows - 当我在 Windows 上克隆带有符号链接(symbolic link)的存储库时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11662868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com