Copy Git project to new repo with submodules in tact using sourcetree

489 Views Asked by At

What I'm trying to accomplish I'd like to copy a wordpress "starter theme" I put together with a library of submodules from various repos. (Ex. normalize-css or scrollmagic). It works nicely in my current project folder but when I try to copy the theme to a new folder, rename the parent theme folder, then add it to a new repo, I can't get it to show up in sourcetree. It just wants to add the submodule files into the main repo like regular files.

What I've tried: First I copied the starter theme folder to a new location and gave it a new name. I then updated the files within to reflect the new folder name in the following areas: "module .git file" residing within the submodule folder, in the "project root .gitmodules file". I also noticed that in the project root .git folder, a modules folder shows up in there as well. I'm not sure what to do with that. I copied it over to the new .git folder location and updated the config file with the appropriate folder name change on a couple as a test but didn't seem to do anything. A side note I also tried sub-repos but also had trouble with that.

Is this something I will have to manually add to each new project or is there a way to transfer these to a new repo?

Original folder structure | New folder structure comparison below (if it helps) enter image description here

1st is the branch I start with and New is the branch I copied over.

enter image description here enter image description here

1

There are 1 best solutions below

3
On

when I try to copy the theme to a new folder, rename the parent theme folder, then add it to a new repo, I can't get it to show up in sourcetree

It just wants to add the submodule files into the main repo like regular files.

Then you need to make sure you do copy only files, not any .git subfolder.
If you have a .git subfolder, SourceTree will only show you the root directory of that submmodule content, as a nested Git repo.