如何将大型二进制文件从主仓库移动到Git子模块?

3
我有一堆视频存放在名为“videos”的目录中。我不幸地把这个巨大的文件夹提交到了git,导致git在某些活动(如克隆)时非常缓慢。因此,我进行了一些研究,并发现了git子模块,但我似乎不是很理解它们。
这是我所做的:
  1. I created a separate repository just for the videos at ssh://dev.example.org/var/git/project/microsite_videos and put the videos in there.
  2. I deleted the videos from my main repo at ssh://dev.example.org/var/git/project/microsite and committed the delete. I realize this doesn't remove the videos from history, but I wanted to make sure I understood submodules before I change history.
  3. I added the videos back as a submodule:

    git submodule add ssh://dev.example.org/var/git/project/microsite_videos videos
    
  4. I committed these changes to master.

这是我的.gitmodules文件:

[submodule "videos"]
    path = videos
    url = ssh://dev.example.org/var/git/project/microsite_videos

一开始看起来还好,但是我对它的某些行为感到困惑。特别是刚才我将主分支合并到一个分支时,视频文件夹就消失了。.gitmodules文件仍然存在,但是任何尝试拉取或更新视频文件夹的操作都只会给我一个新提示,而不会做任何事情。

我做错了什么,如何提高对子模块的理解,以便在每次尝试分支和合并时不必挣扎?

1个回答

1

不要忘记,子模块只是指向特定存储库的特定提交的指针。
请参见 "Git submodules: Specify a branch/tag"。

这意味着,在合并后,您仍然拥有指针(在.gitmodules中和作为树中的特殊条目),但您需要使用git submodule update来刷新子模块内容。
如果更新失败,请参见 "Git submodule head"。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接