Referring to the same submodule twice

I have two code libraries A and B and have started developing an application M.
All three of these are stored in their own repository.

My problem is that I have a dependency such that A uses submodule B, but M uses both submodules A and B.

  • How to remove duplicate file tracking in Git
  • Remote branch with multiple local tracking branches
  • Run Git GUI and Tortoise GUI in parallel
  • Stage only those files containing a specific change in Git
  • Git repository not found
  • Git Installation on OSX: Cannot exec 'git-credential-osxkeychain': Bad CPU type in executable
  • As far as I can tell I’ll have two copies of the same submodule B for the same main project. But it would never make sense (in this setup) for them to be different, as they represent the same library in the same application.

    Is there a way to work around this, so that when I work on M I have only one copy of A and B?

  • Merge a range of revisions with Git or TortoiseGit
  • Can intellij show me the changes of the last x commits as if they were just made?
  • Can't push to GitLab repository from local server (hooks declined?)
  • Gitignore Exceptions Not Being Added to Tracking
  • Is it possible to move a bunch of files from one git repository to another while preserving (most) history?
  • Determining if a Git repository contains a particular commit
  • 2 Solutions collect form web for “Referring to the same submodule twice”

    M--/
       |-- A
       |   |-- B
       |
       |-- B
    

    Just remove M/B submodule from M, and keep/use M/A/B.

    The reasons:

    1. For A submodule(a independent repository), it must needs B for something.
    2. For M repository, you can teach it to use M/A/B.

    As i understand in your app M hierarсhy is something like this:

    M /
      |- A /
           |- B
    

    So to add submodule B to A you should do (in folder A)

    git submodule add git@github.com:username/B.git
    

    For the app M you should do the same but with path to existing B (in folder M)

    git submodule add git@github.com:username/B.git A/B
    
    Git Baby is a git and github fan, let's start git clone.