I’m new to git and would appreciate help with adding submodules.
I’ve received two projects sharing some common code. The shared code was just copied into the two projects. I created a separate git repo for the common code and removed it from the projects with the plan to add it as a git submodule.

I used the path option of git submodule add to specify the folder:

git submodule add url_to_repo projectfolder

but then got the error:

'projectfolder' already exists in the index"

This is the desired structure of my repository:

repo
|-- projectfolder
    |-- folder with common code

It is possible to add the git submodule directly in the repo, or into a new folder there, but not in the project folder. The problem is that it really need to be in the project folder..
What can I do about this and what have I misunderstood about the path option of git submodule add?

12 Answers
12

Leave a Reply

Your email address will not be published. Required fields are marked *