Within three years of Git's appearance, GitHub emerged. GitHub is basically a web service built on top of the Git version control system. It enables developers to easily post their code online, where others can simply clone their repository and use their code. Creating an account on GitHub is free and can be done by following instructions on their official homepage (https://github.com).
Currently, our application is structured as per the following image:

What we want to do is to split it into six different Git repositories, as follows:
corecatalogcustomerpaymentsalesshipmentThe core repository is to contain everything except the content of the src/Foggyline directory.
Assuming we created an empty core repository on GitHub, and our local all-in-one app is currently held in the shop directory, we initialize the following commands on our computer:
cp -R shop core-repository rm -Rfcore-repository/.git/ rm -Rfcore-repository/src/Foggyline/* touch core-repository/src/Foggyline/.gitkeep cd core-repository git init git remote add origin git@github.com:<user>/<core-repository>.git git add --all git commit -m "Initial commit of core application" git push origin master
At this point, we merely pushed the core application part of our all-in-one web shop app into the core repository on GitHub. The src/Foggyline/ directory does not contain any modules in it.
Now, let's go back to GitHub and create an appropriate empty repository for each of the five modules, that is, catalog, customer, payment, sales, and shipment. We can now execute a set of console commands for each of the modules, as shown in the following CatalogBundle example:
cp -R shop/src/Foggyline/CatalogBundle catalog-repository cd catalog-repository git init git remote add origin git@github.com:<user>/<catalog-repository>.git git add --all git commit -m "Initial commit of catalog module" git push origin master
Once all of the five modules are pushed to a repository, we can finally treat them as submodules, as shown here:
cd core-repository git submodule add git@github.com:<user>/<catalog-repository>.git src/Foggyline/CatalogBundle git submodule add git@github.com:<user>/<customer-repository>.git src/Foggyline/CustomerBundle git submodule add git@github.com:<user>/<payment-repository>.git src/Foggyline/PaymentBundle git submodule add git@github.com:<user>/<sales-repository>.git src/Foggyline/SalesBundle git submodule add git@github.com:<user>/<shipment-repository>.git src/Foggyline/ShipmentBundle
If we were to run the ls-al command within the core repository directory now, we should be able to see a .gitmodules file in there with the following content:
[submodule "src/Foggyline/CatalogBundle"] path = src/Foggyline/CatalogBundle url = git@github.com:<user>/<catalog-repository>.git [submodule "src/Foggyline/CustomerBundle"] path = src/Foggyline/CustomerBundle url = git@github.com:<user>/<customer-repository>.git [submodule "src/Foggyline/PaymentBundle"] path = src/Foggyline/PaymentBundle url = git@github.com:<user>/<payment-repository>.git [submodule "src/Foggyline/SalesBundle"] path = src/Foggyline/SalesBundle url = git@github.com:<user>/<sales-repository>.git [submodule "src/Foggyline/ShipmentBundle"] path = src/Foggyline/ShipmentBundle url = git@github.com:<user>/<shipment-repository>.git
The .gitmodules file, basically, contains the list of all of the submodules added to our core project, that is, core application. We should commit and push this file to the core repository now. Assuming that the .gitmodules file is pushed to the core repository, we can easily delete all directories created so far and initiate the project with one simple command, as follows:
git clone --recursive git@github.com:<user>/<core-repository>.git
The --recursive argument to the git clone command automatically initializes and updates each submodule in the repository based on the .gitmodules file.