This feature exists already. It's called git.