Git 和硬链接 [英] Git and hard links

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

问题描述

考虑到 Git 无法识别指向存储库外部的符号链接,使用硬链接有什么问题吗?

Considering that Git does not recognize symbolic links that point outside of the repository, is there any problem using hard links?

Git 能破解它们吗?你能指点我详细的信息吗?

Could Git break them? Can you please point me to detailed information?

推荐答案

'tree' 对象,代表 Git 中的目录,存储文件名和(的子集)权限.它不存储 inode 编号(或其他类型的文件 ID).因此硬链接 不能在git中表示,至少在没有诸如metastoregit-cache-meta (我不确定即使使用这些工具是否可行).

The 'tree' object, representing directories in Git, stores file name and (subset of) permissions. It doesn't store inode number (or other kind of file id). Therefore hard links cannot be represented in git, at least not without third party tools such as metastore or git-cache-meta (and I am not sure if it is possible even with those tools).

Git 尽量不接触不需要更新的文件,但您必须考虑到 git 不会尝试保留硬链接,因此它们可能会被 git 破坏.

Git tries to not touch files that it doesn't need to update, but you have to take into account that git doesn't try to preserve hardlinks, so they can be broken by git.

关于指向存储库外部的符号链接:git 对它们没有问题,应该保留符号链接的内容……但我怀疑这些链接的效用,因为这些符号链接是否会被破坏与否取决于外部 git 存储库的文件系统布局,并且不受 git 的控制.

About symbolic links pointing outside repository: git has no problems with them and should preserve contents of symbolic links... but utility of such links is dubious to me, as whether those symlinks would be broken or not depends on the filesystem layout outside git repository, and not under control of git.

这篇关于Git 和硬链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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