从另一个 git 存储库链接单个文件
如何将另一个 git 存储库中的单个文件链接到您自己的存储库?我不需要完整的存储库,只需要一个文件。使用 git submodule 似乎是正确的路线,但它想要抓住整个事情。
How do you link a single file from another git repository to your own repository? I don't want the full repository, just a single file. Using git submodule
seems like the right route to go, but it wants to grab the whole thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑到 git 的工作单元是一个存储库(或更准确地说是一个存储库内容),我认为您无法轻松集成一个文件。
如果您不需要它的历史记录,您可以考虑将其复制到您的存储库中。
但如果你确实需要历史记录,那么一些 git filter-branch (如“git:如何从项目中分离库?filter-branch,子树?”)是有序的。不过,对于一个文件来说,这似乎需要付出很大的努力。
理论上,“git:符号链接/对外部存储库中文件的引用”建议了一种结合子模块和符号链接的解决方案。< br>
(来自 Pavel Šimerda)
自 2011 年(上面的原始答案)以来,Gavriel 报告在评论中:
Considering that the unit of work for git is a repository (or more precisely a repository content), I don't think you can easily integrate one file.
If you don't need its history, you could consider simply copy it in your repo.
But if you do need the history, then some
git filter-branch
(as in "git: How to split off library from project? filter-branch, subtree?") are in order. That seems a lot of effort for just one file though.In theory, "git: symlink/reference to a file in an external repository" suggests a solution combining submodule and symlink.
(from Pavel Šimerda)
Since 2011 (original answer above), Gavriel reports in the comments that: