Can I put a .gitmodules file in a subdirectory?

Let’s say my repo index root is in /project dir.
Should the .gitmodules also be inside this dir, or can I put it into, say /project/subdir?

The reason I would like to do that is because I have multiple contributors and I want each to be responsible for his own set of submodules.

  • Does “git stash apply” or “git stash pop” also adds the modified files for commit?
  • Why does a merge need you to consider the common ancestor?
  • cut next placeholder with git pretty format e.g. to cut a date string
  • git-svn clone server sent unexpected return value (303 see other)
  • Import separate SVN directories as git branches
  • How to Test if Git Repository is Shallow?
  • GIT deleted my local files
  • Vagrant: install git using Chef
  • Which files/folder should be in version control for Sencha Touch 2
  • W access for gitolite-admin DENIED to user
  • My project uses over 100 git submodules, which submodule alternative can handle a lot of repositories gracefully
  • Git merge & adding change id
  • One Solution collect form web for “Can I put a .gitmodules file in a subdirectory?”

    man gitsubmodule on Debian Wheezy says:

    ...
    SYNOPSIS
       $GIT_WORK_DIR/.gitmodules
    ...
    

    According this default place for .gitmodules file is a top-level directory of the git working tree.
    So, lets say you have such project structure:

    project/
    |
    |--subproject-1/
    |  `--.gitmodules
    |--subproject-2/
    |  `--.gitmodules
    |--.gitmodules
    

    .gitmodules in your project root dir will define modules subproject-1 and subproject-2. Subprojects dependent modules also can be defined with subproject-N/.gitmodules, but those settings will affect only in proper subproject scope.

    To update your project dependencies you should use command:

    git submodule update
    

    But if you want to update also dependencies of subproject-1 and subproject-2 use:

    git submoudle update --recursive
    
    Git Baby is a git and github fan, let's start git clone.