git commit symlink作为常规文件 [英] git commit symlink as a regular file
问题描述
假设我有一个文件 fname
,它是来自其他资源库/项目的文件的符号链接,比如 ../../ proj2 / fname
。
Suppose I have a file fname
which is a symlink to a file from some other repository/project, say ../../proj2/fname
.
有没有方法可以添加/提交 fname
作为常规文件?
Is there a way to add/commit fname
as a regular file?
看来,默认情况下,git会给出文件模式120000,并将链接文件的路径设置为blob内容。
It seems that, by default, git gives the file mode 120000 and sets the path to the linked file as the blob content.
我知道这是因为 git ls-tree
显示文件的模式120000, git cat-file -p
显示 ../../ proj2 / fname
作为blob的内容。
I know this because git ls-tree
shows mode 120000 for the file, and git cat-file -p
shows ../../proj2/fname
as the blob's content.
推荐答案
不,Git知道它是一个符号链接。这对于Git来说是非常危险的,否则它会写入到 文件之外的文件中。将它作为符号链接进行跟踪恰恰是预期的行为。
Nope, Git knows it's a symlink. It'd be kind of dangerous for Git to pretend otherwise, since it would then end up writing to files outside the repo. Tracking it as a symlink is exactly the intended behavior.
这篇关于git commit symlink作为常规文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!