简体   繁体   English

Git不在Windows上将符号链接存储为符号链接

[英]Git not storing symlink as a symlink on Windows

I have a project that contains three top-level directories: 我有一个包含三个顶级目录的项目:

A
B/dir1
C/symlink_to_dir1

As you can see, we're symlinking from a directory in C to another in B. These three directories are stored in a single Git repository on Windows, but we're having a problem when we try to commit the symlink. 正如您所看到的,我们将从C中的目录符号链接到B中的另一个目录。这三个目录存储在Windows上的单个Git存储库中,但是当我们尝试提交符号链接时,我们遇到了问题。 It was my understanding that Git would store the symlink as just that, and unpack it as a symlink in any repo this one was cloned into. 我的理解是,Git会将符号链接存储为,并将其解压缩为任何一个克隆中的符号链接。

However, when we stage the symlink, it's the files in dir1 themselves that are added instead of the link itself. 但是,当我们使用符号链接时,它是dir1本身的文件,而不是链接本身。 When we make the commit, git status will tell us the working directory is clean but git add -A will delete all the files from the symlinked directory and tell us that the symlink is untracked. 当我们进行提交时, git status将告诉我们工作目录是干净的但git add -A将删除符号链接目录中的所有文件,并告诉我们符号链接未跟踪。 This happens immediately after we make the commit, without any actions having taken place. 这在我们进行提交后立即发生,没有发生任何操作。

Our desire is to preserve the symlink so we don;t have to restore it each time we clone the repository, and it was my understanding that this was the default behaviour in Git. 我们希望保留符号链接,以便我们不必每次克隆存储库时都要恢复它,而且我理解这是Git中的默认行为。 Can anyone please tell me what we're doing wrong here? 谁能告诉我这里我们做错了什么?

If you are using Git for Windows based on msysgit , then the answer simply is that symbolic links (as introduced by Windows Vista) are not supported, even if core.symlinks is set to true. 如果您正在使用基于msysgit的Git for Windows ,那么答案就是不支持符号链接(由Windows Vista引入),即使core.symlinks设置为true也是如此。 For reference, you may want to look at this discussion , but please keep in mind that the issue tracker on Google Code is closed (in favor of the one at GitHub). 作为参考,您可能希望查看此讨论 ,但请注意Google代码上的问题跟踪器已关闭(有利于GitHub上的问题跟踪器)。

However, there seems to be a fork that implements symlink support , but that work has not yet been merged into msysgit. 但是,似乎有一个fork实现了符号链接支持 ,但该工作尚未合并到msysgit中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM