Add Flutter as a git submodule to your project

awaik
1 min readFeb 17, 2024

Git submodules allow you to embed one Git repository within another.

  • Nested Projects: Think of a project with components that are also managed as separate Git repositories. Submodules let you include those components directly within your main project.
  • Version Control: You control the exact version (commit) of each submodule used in your main project, ensuring code consistency.
  • Independent Development: Work on the main project and its submodules can happen in parallel.
  • Drawbacks: Submodules can add complexity to your project management, so only use them when you have a clear need for this structure.

Sometimes we need to add Flutter as a submodule to the project (for example for the CI).

I prefer creating a separate folder inside the project, such as submodules.

After that navigate to this folder and run a command

git submodule add -b stable git@github.com:flutter/flutter.git

Now you have a stable branch in the folder ./submodules/flutter

Now, how we can update it?

git submodule update --recursive --remote

That’s it. Happy coding!

--

--