How to ‘flatten’ a Git repository with multiple submodules

A common strategy during development is to use multiple git submodules. In this way you may distribute the workload to other developers but also maintain a proper structure of your project. However, when it is time to release, a good advice is to ‘flatten’ your repository and ensure that your project is self-contained in a way that there will be no (external) dependency to other...