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.

  • Exact way of ignore/unignore files in git
  • Confused by git checkout
  • How to add library to forked cdnjs repo?
  • Angular error for Include BrowserAnimationsModule
  • Git: How to recover stashed uncommitted changes
  • Searching git commits for a particular change
  • 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?

  • Should *.xccheckout files in Xcode5 be ignored under VCS?
  • Remove Git from my mac?
  • How is the git name determined when committing and pushing
  • Cannot push to GitHub - keeps saying need merge
  • Multiple “git add” before “git commit”
  • push an 'unchecked out' branch
  • 2 Solutions collect form web for “Referring to the same submodule twice”

       |-- 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

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

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