3

I'm trying to add a submodule to an existing project. I followed the instructions at How to set up a git project to use an external repo submodule?, but the directory structure is wrong. I am aiming for a "it just works" so users are not hassled.

The initial clone and submodule process:

git clone https://github.com/weidai11/cryptopp.git
cd cryptopp
git submodule add https://github.com/noloader/cryptopp-autotools.git
git submodule update --remote

The submodule only has one file at the moment, and its a README.md:

$ find . -name README.md
./cryptopp-autotools/README.md

What I need to accomplish is, add the submodule's files to PWD and not the subdirectory cryptopp-autotools.

How do I setup the submodule such that the submodule's files are in PWD and not subdirectories?


The Git Submodules man page seems to indicate we can specify a <path>, but here's the result of trying to do so:

git clone https://github.com/weidai11/cryptopp.git
cd cryptopp
git submodule add https://github.com/noloader/cryptopp-autotools.git $PWD
git submodule update --remote

'/home/jwalton/cryptopp' already exists in the index
jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    A submodule always exists in a directory separate from the parent project (because a submodule is a git repository). You can't merge two separate repositories into the same work tree. – larsks Nov 01 '17 at 15:40
  • Thanks @larsks. It sounds like submodules are the wrong tool for the job. What should we do to merge the files from two different locations into a single project? Branches are not an option because they pollute the log files. We stopped using branches and switched to unique repos. – jww Dec 16 '17 at 03:51
  • It sounds like you're trying to use `git` as a software distribution mechanism (" I am aiming for a "it just works" so users are not hassled."). That's not really what it was built for. If you really need to work with separate repositories, I would learn to love either `git submodule` or `git subtree` and re-arrange things so that your project works with the directory structure implied by either of these solutions. – larsks Dec 16 '17 at 03:59

0 Answers0