Do you ignore a git submodule in your .gitignore or commit it to your repo?

I’ve added a submodule to my project in project_dir/vendor/submodule_one now each time I run git status I get modified: vendor/submodule_one (new commits).

My question is whats the best way to deal with this? Do I add the vendor/submodule_one-folder to my .gitignore as my main project shouldn’t need to know about the specifics of my submodule?

  • How to find all uses of a blob in a git repo
  • Checkout source files from local git repo to local folder
  • Git case-sensitivity error — renaming and committing from Android Studio
  • EGit and multiple “users” on same machine
  • Selectively merging *parts* of a file with git?
  • git-python get commit feed from a repository
  • Or when I’m changing and commiting changes to my submodule do I need to make commits in my main project also?

    Just getting started with submodules and couldn’t seem to find much info beyond setting them up.

  • GIT can't pull: failed to symlink 'path/filename': File name too long
  • How can I push changes directly from Cloud9 IDE to Heroku?
  • Git adding “unchanged” files to the stage
  • Cloning a Non-Standard Svn Repository with Git-Svn
  • git-subtree without squash: view log
  • Cannot access remote git repository
  • One Solution collect form web for “Do you ignore a git submodule in your .gitignore or commit it to your repo?”

    No, you don’t need to add your submodule to your .gitignore: what the parent will see from your submodule is a gitlink (a special entry, mode 160000).

    That means: any change directly made in a submodule needs to be followed by a commit in the parent directory.
    That way, the parent directory will record the right commit for the state of the submodule: That commit is the “gitlink” mentioned above;

    You can read more about that policy in “git submodule update (true nature of submodules)”.
    The main idea behind submodules is a component-based approach, where you reference other repos at specific commits. But if you change anything in those submodules, you need to update those references in the parent repo as well.

    Note that with Git 2.13 (Q2 2017), while not ignoring the gitlink, you can still ignore the submodule with:

    git config submodule.<name>.active false

    See more at “Ignore new commits for git submodule”.

    Git Baby is a git and github fan, let's start git clone.