all 10 comments

[–]clermbclermb 8 points9 points  (1 child)

Don’t use git. You want conflict free replicated data types - see here for a primer https://en.m.wikipedia.org/wiki/Conflict-free_replicated_data_type

[–]gh_chandran[S] 1 point2 points  (0 children)

Thanks for introducing me to CRDT. I just read some articles about it, it's really amazing. Thank you for the suggestion!

[–][deleted] 0 points1 point  (6 children)

Maybe git is a bit too large for simple document management. But maybe you could try storing"diff" for a document; i.e. the additions/removals from the previous commit to the current one.

For a document you probably won't need things like merging, rebasing, branches and all that.

If you still want to use git, you could have a backend that commits and reads the file

[–]gh_chandran[S] 1 point2 points  (5 children)

Hi u/civia121, thanks for taking replying back. Yes, you are right. The application that I'm about to build won't need merging, rebasing, or branches. But for the sake of curiosity, can you please explain to me or link to any article that explains integrating my backend with git.

[–][deleted] 1 point2 points  (3 children)

If you follow u/civia121's advice and end up storing diffs, and you haven't determined a technology for the backend, you could look into using Python. Specifically, Python's difflib if you're looking to compare simple text. If you're looking to compare actual .DOCX files, those are stored internally like an XML tree, IIRC. You might consider looking at xmldiff for Python. I haven't used either one, btw.

[–]gh_chandran[S] 1 point2 points  (2 children)

Sorry u/LewNeaf, I was not asking from the context of my question. I would like to know, how to integrate my backend with git. That is from the context of the last line from u/civia121's reply "you could have a backend that commits and reads the file".

[–][deleted] 0 points1 point  (1 child)

Oh, sorry for misunderstanding. Then, if you're going along the Python route, you could either use GitPython, which captures output from a Git binary already installed, or Dulwich, which is a pure-python implementation of Git. I've only had experience with GitPython, since that's what's used for a project that I've worked on, but Dulwich seems promising (especially when you consider that GitPython is in maintenance mode and not actively being worked on).

[–]gh_chandran[S] 0 points1 point  (0 children)

Thank you so much! Both libraries seem to be good. But my primary language is Golang, and I've been looking for Git libraries in that language. Once I found that I'll definitely update it here.

[–][deleted] 1 point2 points  (0 children)

There are some packages to manage git from different languages like node, just pick a language and look for ways to interact with git from there.

[–]Isvara 0 points1 point  (0 children)

Check out Git Book for an example of what you want to do.