2 Meld - rciak/zz_42_shared_notes GitHub Wiki

In a nutshell ...

  • Meld is a quite good free optical diff-tool with editing capabilities, that can be used to compare files containing code or other types of text, and even complete folders.
  • It combines nicely with git, enhancing merging / conflict resolution as well as viewing/editing differences.

Features

Meld is useful for local diffs and in combination with git.

  • Differences between folders and files can be displayed and edited by meld. For files this includes:
    • Highlighting of not only text blocks that differ, but also of differences inside these blocks.
      (A big advantage in comparison to a usual diff command!)
    • Comparison of exactly chosen Text blocks can be achieved by Synchronisation points.
    • One Clic editing of differing text blocks for common actions like replace text block or delete text block.
      Editing a file on the way is possible as well.
  • Meld can be combined nicely with git, enhancing viewing differences and potentially also merging:
    • Show differences, .e.g. those done since the last commit, or those that happened to a file between two specific commits.
    • Meld can be helpful in resolving merge conflicts.

Setup

Meld, can be installed via the 42 Package Manager, cf. the installation guide.

Examples for local use (independent of git)

The provided arguments are sample names for files or folders. Please addopt them to your own stuff as you need!

  • Start from console:
    flatpak run --file-forwarding org.gnome.meld
  • Show diffs between two files:
    flatpak run --file-forwarding org.gnome.meld Makefile ../05_Push_swap/Makefile
  • Show diffs between two folders:
    flatpak run --file-forwarding org.gnome.meld 07_fractol tmp_for_diff_07_fractol

Examples for use in connection with git

The provided arguments are sample names for files or folders. Please addopt them to your own stuff as you need!

  • Ensure local changes are really like intended before a git add / git commit command
    • Variant A (recommended in most cases): Please ask me which changed files I would like to see
      git difftool, if prompting is set as default¹, or otherwise git difftool --prompt.
    • Variant B: Show me differerences in all files that have changes without asking me which one I would like to see
      git difftool --no-prompt
  • Show the differences between two different commits
    • Show first with git log the two git commit id or their short version, by e.g.
      git log --oneline --graph --all
    • Pick the wanted commits from the printed list, say e.g. 1d86e2f and 207a5ef, and then view the differences for them via the command
      git difftool 1d86e2f 207a5ef
  • Use meld as mergetool (when a conflict has occured) git mergetool

¹ The configuration file provided in the installation guide makes this currently (26.07.2024) the default (in contrast to the older version on Discord where the opposite had been set as default).