First, you must have some version control system, like git. Just to be able to rollback if you deleted something important, or to find edition history.
Next, you automatically have production-ready tools and infrastructure to share your knowledge between teammates. In local install, you can use things like GitLab.
Maybe your git-enabled infrastructure should be tuned to notify you when your colleague changes something, and you should git pull from the shared repo to admit changes locally. I’m not sure it can be done automatically – at least you should be able to check first the diff between local and remote repo before merging.