I'm collaborating using git on bitbucket (for a free private cloud
repository) and SourceTree for Windows on an article in LyX (2.2.2). There
are multiple image files (e.g., generated by R in SVG) and a big .bib file.
For the record, I'm not really using LyX's built-in version control, as it
doesn't recognize the other files that might change. SourceTree is very
visual and saves you from memorizing the cryptic git command lines;
although when you get stuck, you can still type them in a git bash window.

Yesterday, I had to merge some changes from another author, which took
(too) much of my time using the git-oriented way. We had both (somewhat
simultaneously) updated the same section of the article, and that section
got moved in one version. But resolving merge conflicts is also harder
because LyX source is not really meant to be human readable (and I use LyX
for the precise reason that I don't want to look at typesetting source). I
wonder, too, if git doesn't use syntax hints to help identify blocks of
code (e.g., balanced parentheses and brackets, which are used in many
programming languages but not so much in .lyx files).

When I pulled the changes (my local branch was out of sync by half a day),
there were conflicts. I'm not new to merging, but it's the first time I've
done it with a LyX file. I have configured SourceTree to use the kdiff3
tool, which did a great job to help me out (it resolved most of the
conflicts, but about 20% required manual intervention, where you basically
have to decide between version A, B or C in three separate windows for each
conflict). In the end, I was very conservative and wound up with some
duplication in the final document (the section that was moved). Finally, I
met with the co-author in person and was able to resolve some conflicts
that were redundant. I was actually just happy the LyX file wasn't corrupt
after the merge! I suppose this same problem would occur in source code,
but given that code has to function to pass tests, it's not quite the same
work flow. Editing academic publications is different than writing software
in this way. But I digress...

Alternatively, I could have cloned the head origin version before I merged
and and just resolved the differences in separate LyX windows using
copy/paste by hand, But with no tool to show differences, that is also not
ideal. The other strategy is to agree ahead of time not to touch the same
parts of the document in parallel. But these just seems counterproductive
when you're using source code control! Related humor: https://xkcd.com/1597/

What's your preferred way to merge changes and manage conflicts in LyX
files under git?

Reply via email to