We built a C++ project-based course [0] that uses exactly the same ideas.
The core of our approach is that every code snippet is extracted from a fully working codebase and every code iteration is tracked in git.
We unit-test each commit, which means that every tutorial step works. Also, making a change in an early code iteration requires a proper git rebase, with the change propagating through history without conflicts.
We also annotate the code to extract snippets, and then run scripts to autogenerate git diffs for those snippets. The scripts also output the unannotated version of the codebase, which we share with the course participants.
We are thinking about writing a blog post about this if there's interest!