I'd like to change one folder in my project into a submodule. This is my (sumplified) directory structure:
|-app <- the root of git project
|--themes
|--plugins
|--lib
Now, I want to turn app/plugins into a submodule so that I commit changes in this directory into a separate reposiotry.
After setting up a new repo for plugins, I've tired git submodule add <submodule-repository> plugins
, but then I receive a message the reads
app/plugins' already exists in the index
Sure it exists in the index since it was tracked as part of the main project repository.
How should I solve it? Should I perhaps delete the main .git
folder, add app/plugins
to .gitignore, commit again, and then run git submodule add
?
This actually raises another question, should a folder that is a submodule of the project be added to .gitignore
of the project that includes the submodule?
I managed to answer my own question. Perhaps I posted too soon. Nevertheless maybe it will help some people in the future:
In order to turn a folder tracked in the current project into this project's submodule, I took the following steps:
git rm -rf <folder_that_will_be_a_submodule>
;rm -rf
;.git
lives);git submodule add <repository>
;.gitignore
(if it has been referenced there).Hope it will help somebody.