Hi fellow LyX users,

Just wanted to share with you how it's possible to use the compare feature of LyX to resolve git merge conflicts by registering LyX as a merge tool for git:

You can add the following snippet to your ~/.gitconfig file:

For UNIX systems (should work but didn't test since i'm on Windows):

[mergetool "lyx"]
cmd = \"/path/to/lyx" -x \"dialog-show compare run \\\"`realpath \"$LOCAL\"`\\\" \\\"`realpath \"$REMOTE\"`\\\"\"

and for Windows:

[mergetool "lyx"]
cmd = \"C:\\Program Files (x86)\\LyX_2.3\\bin\\lyx\" -x \"dialog-show compare run \\\"`cygpath -wa \"$LOCAL\"`\\\" \\\"`cygpath -wa \"$REMOTE\"`\\\"\"

When you have a git-managed LyX file with merge conflicts you can then run "git mergetool -t lyx path/to/file.lyx" from inside the git repository of that file.

This should make LyX start up in compare mode and give you the ability to accept / reject the changes. When finished, you need to override the conflicted file with the generated changes1.lyx file, close the LyX window and confirm to git that the merge was successful.

This strategy could maybe also be adapted to other VCS if they have the possibility to generate local and remote file without conflict markers.

the important part is the LyX Function to start the comparison process:

"dialog-show compare run /path/to/oldfile /path/to/newfile"

(By the way there is bug item #8440 <https://www.lyx.org/trac/ticket/8440> requesting such a function. Wanted to add this as comment, but i don't have an account in the bug tracker yet and it seems like registering is disabled)

Should i write about this in the LyX Wiki? Where would be a good place for it? maybe <https://wiki.lyx.org/Tips>? or <https://wiki.lyx.org/Devel/Collaboration#toc6>?

Hoping someone will find it useful.

Yours, Markus
lyx-users mailing list

Reply via email to