> He just analyzes how I did this and after some time secretly re-implements it from scratch with very minor changes or additions.

The answer here has to be **Code review.**

Incorporate it into your workflow, then there's no "secret code" being committed. (The fact someone can commit code in semi-secret is kind of an issue in itself.)

He then has to work in a branch and have his re-implementation signed off by at least one other developer before pushing to master. If he tries to get weird re-implementations for no clear reason signed off with minor changes, then that will immediately raise red flags to any half-competent reviewer.