Know when to use hooks, submodules and Git LFS
Know when to use hooks, submodules and Git LFS
Some repositories need extra mechanisms: automated checks before commits, a separate repository embedded as a dependency, or storage suited to large binary files. These are advanced tools, not defaults every project needs.
What you’ll learn
- Recognize hooks, submodules and LFS.
- Choose simpler alternatives when appropriate.
- Know that these tools require team setup.
Advanced tools solve specific problems
Hooks
Run local automation around Git events.
scriptsSubmodules
Pin another repository at a commit.
nested repo referenceLFS
Track large-file pointers while storing content separately.
large binaries
Use advanced features only for a concrete repository need
Hooks run scripts at specific Git events on a machine. Submodules let one repository record a specific commit of another repository. Git LFS stores lightweight pointers in Git while large file content is handled by LFS storage.
Each tool adds operational expectations for teammates and CI. Document setup clearly. For simple source projects, ordinary Git plus a package/dependency manager is often easier.
Recognize advanced repository features
Run this in a disposable practice repository unless the lesson explicitly says otherwise.
git submodule status
git lfs version
# Local hooks, when used, live under .git/hooks by defaultThese commands are orientation checks, not requirements for this course. Git LFS must be installed separately in many environments, and a repository only needs submodule commands if it actually uses submodules.
Practice: Advanced Git tools
Your task: For three scenarios—generated build output, a 2 GB binary model file, and a reusable library maintained as its own repository—explain whether .gitignore, Git LFS, a package manager or a submodule might be appropriate.
Common pitfall to avoid
Do not introduce submodules or LFS merely because a repository is large. Choose them based on file type, distribution needs, dependency ownership and hosting constraints.
Check your understanding
Advanced Git tools: what to remember
Know when to use hooks, submodules and Git LFS is complete when you can explain the state being changed before you run the command, not merely repeat the syntax.
Read further: official supporting documentation.
Reaching the recap and completing the quizzes are separate milestones.