3

I have a bunch of videos inside a directory named "videos". I committed that unfortunately large folder to git, causing git to become very slow for some activities such as cloning. So I did some research and discovered git submodules, but I don't seem to understand them very well.

Here's what I did:

  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.

Here is my .gitmodules file:

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

At first it seemed to work OK, but I'm confused about some of its behavior. In particular, just now I merged master into a branch and the videos folder just disappeared. The .gitmodules file is still there, but any attempt to pull or update the videos folder just gives me a new prompt without appearing to do anything.

What am I doing wrong, and how can I improve the my understanding of submodules so I don't have to flounder every time I try to branch and merge?

kojiro
  • 74,557
  • 19
  • 143
  • 201

1 Answers1

1

Don't forget that submodules are just a pointer to a specific commit of a specific repo.
See "Git submodules: Specify a branch/tag".

Meaning that, after your merge, you still have your pointer (in .gitmodules and as a special entry in the tree), but you need a git submodule update in order to refresh the submodule content.
See "Git submodule head" if that update should fail.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250