I use LaTeX for two different things: My mathematics thesis, and writing a novel (because who isn't an amateur novelist these days?). From my experiance with Vimdiff (diff as a back end) merging different sets of edits together is horribly painful. I spent more time merging edits in a particular chapter once then I did writing it. Diff does a horrible job of actually identifying what hasn't changed. It wants to delete a paragraph and then add it back in a slightly different way later among a ton of other paragraphs.
What I find often happens is that Diff will falsely flag a bunch of lines/paragraphs as having been changed when in fact they have not. This is the source of my problems--wading through the false positives. Diff suggests deleting perfectly good lines to add them back in. there is a bit more to it than that, but that is the gist of it.
However, this is with a two-way merge. Does a three-way merge mitigate this?
- I write a chapter
- branch at the end of that chapter and then edit it.
- I write another chapter to give myself time to forget my preconcieved notions of what the previous chapter should be like (easier to kill darlings and identify when details are missing)
- I then go to the previous chapter, uneditted, and edit it again.
- I merge this group of edits into the first set of edits (this is what hurts).
So what I want to do is write a chapter in the "Writing" branch. This way I have an easy way to see exactly what my story looks like without any edits. Good for finding regressions.
After committing I then branch this into a "first edit branch". I keep the original manuscript unchanged, and then edit the .tex file making changes.
I check out the writing branch again, after committing to the first edit branch. This time I write another chapter. Supposing I had just finished editing chapter 4, I will be writing chapter 5.
After committing the writing branch, I branch it again to the second writing branch, and do the same thing as I had before.
I then write another chapter in Writing branch, before going in for more edits. This time, instead of branching the writing branch, I merge the second set of edits and the first set of edits together. The edits should be different because I am looking at them at different times. This is useful for me.
And this is the point at which I am concerned. The merger.
How well does Git handle that? I use LOTS of comments, which seems to be the main reason diff gets confused. For what its worth, latex-diff doesn't seem to have these problems, presumably since it is designed specifically for LaTeX.
To be clear, I don't have any practical experience using LaTeX and Git. Before I get myself into something I think could turn VERY messy, I want to better understand if Git can work as I want, or if I should just expect.
I'm not saying diff is useless or itself horrible, just that it is the wrong tool for the job. It also isn't part the question. The question is about Git. Not Diff.
Latex-diff, in my experience, does a great job. Is it possible to use that as a back end? Or something like that? It goes word by word.
This is not about producing a differenced latex document for viewing like in the case of latex-diff or latex-diff-vc (the vc standing for version control). Potentially, I might seek a solution of using latex-diff in place of diff3 (what I've read Git uses).
For what its worth, I'm essentially using this workflow already, but without the aid of branches. I'm hoping that the use of branches will help me suppress commenting out text as a means of version control.
As a side note, this should help improve merging: https://stackoverflow.com/questions/5587626/git-merging-within-a-line. In particular, achoo5000's which is sentence by sentence.