Google docs is the best example for this that we know of.
If I had to build something on these lines which is quick and dirty and makes use of the things that i already know of I would follow this approach.
- Create a github repo.
- All people who want to edit something collaboratively add them to this repo.
- Create a folder called docs in the repo.
- Add one md file every file that all people in repo can collaboratively edit.
- People clone this repo on their machine.
- Open the md file that they want to edit collaboratively.
- Push local change to central repo
- Write a watch script that auto saves the file every second(reduce this over the time) only if there is a local change. commits the diff and pushes it.
- Pull changes from central repo
- Even if there is no change still pull the code every second. No conflict then update.
- If there is a conflict just create a conflict copy that is mapped to the source md file. Look at how dropbox does is beautifully.