gitgit-submodules

Do you need to commit a git submodule or just the gitmodules file


When you add a submodule to your git project - it adds a gitmodules file and pulls down the actual submodule and stores it in your project.

Do I need to commit the actual submodule that's pulled down or is it better to just commit the gitmodules file that describes the path to the submodule?


Solution

  • You will commit automatically both:

    • the .gitmodule
    • the gitlink (special entry in the index of the main repo) which records the SHA1 of that submodule.

    This is reflected in the reverse process (when you want to remove a submodule from a Git repo)