I think you are looking for git.
Discussion
Yeah, just came to the same conclusion, lower down. 😂
i'm not sure if git is precisely suited to single documents though, that's kinda overkill for the multiple files, but for sure the same principle, it would be a block graph of sorts (you could have forks and joins)