Windows 中的 Git 符号链接 [英] Git Symlinks in Windows
问题描述
我们的开发人员混合使用基于 Windows 和 Unix 的操作系统.因此,在 Unix 机器上创建的符号链接成为 Windows 开发人员的一个问题.在 windows (msysgit) 中,符号链接被转换为带有指向文件路径的文本文件.相反,我想将符号链接转换为实际的 Windows 符号链接.
Our developers use a mix of Windows and Unix-based OSs. Therefore, symlinks created on Unix machines become a problem for Windows developers. In windows (msysgit), the symlink is converted to a text file with a path to the file it points to. Instead, I'd like to convert the symlink into an actual Windows symlink.
我必须对此的(更新)解决方案是:
The (updated) solution I have to this is:
- 编写一个结帐后脚本,该脚本将递归查找符号链接";文本文件.
- 将它们替换为与虚拟符号链接"具有相同名称和扩展名的 windows 符号链接(使用 mklink)
- 通过在 .git/info/exclude 中添加条目来忽略这些窗口符号链接
我还没有实现这个,但我相信这是解决这个问题的可靠方法.
I have not implemented this, but I believe this is a solid approach to this problem.
问题:
- 您认为这种方法有哪些缺点(如果有)?
- 这个结账后脚本甚至可以实现吗?即我可以递归地找出虚拟的符号链接"吗?git 创建的文件?
- 有没有人写过这样的脚本?
推荐答案
您可以通过查找模式为 120000
的文件来找到符号链接,可能使用以下命令:
You can find the symlinks by looking for files that have a mode of 120000
, possibly with this command:
git ls-files -s | awk '/120000/{print $4}'
一旦你替换了链接,我建议用 git update-index --assume-unchanged
将它们标记为未更改,而不是在 .git/info/exclude
中列出它们代码>.
Once you replace the links, I would recommend marking them as unchanged with git update-index --assume-unchanged
, rather than listing them in .git/info/exclude
.
这篇关于Windows 中的 Git 符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!