Windows中的Git符号链接 [英] Git Symlinks in Windows

查看:130
本文介绍了Windows中的Git符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的开发人员使用基于Windows和Unix的操作系统。因此,在Unix机器上创建的符号链接成为Windows开发人员的一个问题。在Windows(msysgit)中,符号链接被转换为文本文件,并带有它指向的文件的路径。我想将符号链接转换为实际的Windows符号链接。

/ p>


  • 编写一个递归查找脚本,递归查找符号链接文本文件。它们使用与symlink相同的名称和扩展名的windows符号链接(使用mklink)。
  • 通过向.git / info / exclude添加条目忽略这些窗口符号链接


我没有实现这个,但我相信这是解决这个问题的一个可靠方法。

问题:


  1. 您看到什么方法?

  2. 这个post-checkout脚本甚至可以实现吗?也就是说,我可以递归地找出git创建的虚拟符号链接文件吗?
  3. 有没有人已经在使用这种脚本?


通过查找具有 120000 模式的文件,可以使用此命令找到符号链接:

  git ls-files -s | awk'/ 120000 / {print $ 4}'

一旦您替换链接,我会建议将它们标记出来与 git update-index --assume-unchanged 不变,而不是将它们列在 .git / info / exclude


Our developers use a mix of Windows and Unix based OS's. 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:

  • Write a post-checkout script that will recursively look for "symlink" text files.
  • Replace them with windows symlink (using mklink) with same name and extension as dummy "symlink"
  • Ignore these windows symlink by adding entry into .git/info/exclude

I have not implemented this, but I believe this is a solid approach to this problem.

Questions:

  1. What, if any, downsides do you see to this approach?
  2. Is this post-checkout script even implementable? i.e. can I recursively find out the dummy "symlink" files git creates?
  3. Has anybody already worked on such script?

解决方案

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}'

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆