💾 Archived View for bbs.geminispace.org › s › bash › 16319 captured on 2024-08-18 at 19:36:30. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-07-09)

🚧 View Differences

-=-=-=-=-=-=-

Beginner tips for beautiful diffs?

I largely prefer command line tools, but when it comes to handling merge conflicts I find command line diff tools confusing (e.g. I'm in vimdiff and I've got these panes open - which is which?) and always end up either using a GUI git client like sublime merge to visualize the diff or dive into the file with conflicts and resolve them manually.

Also, there are times when I wish to compare two files or strings. Sometimes I just make some dummy git activity to get a diff between these variants, but most times I just open two splits, paste the contents in each, and visually grok, which you can imagine is time consuming and not very efficient.

Do you have any software or processes that you use when diffing text files, strings, binary files, photos, directory contents, anything? Any simple shell scripts you've made that make these tasks a bit easier?

Posted in: s/bash

🚀 lanterm

Apr 23 · 4 months ago · 👍 norayr

5 Comments ↓

🚀 fripster · Apr 23 at 17:29:

I use Meld and I like it... It is graphical, but I find it clear and easy to understand.

☕️ Morgan · Apr 24 at 06:34:

The only UI that has ever made sense to me for code merges is kdiff3. Others try to collapse too much, in kdiff3 you get four text regions: main, theirs, yours, output. Simple.

Well, not simple, but at least all the complexity is visible :)

🐦 wasolili [...] · Apr 25 at 21:19:

I use vimdiff as my mergetool. The 4 panes are the BASE file (before your changes or the conflicting commits changes), the REMOTE file (the file with the conflicting commits changes), the LOCAL file (the one with your changes), and the MERGED file (the result of git attempting to merge, has git's <<< === >>> stuff added around the merge conflicts, and is where you actually fix the conflict)

I like this setup a lot, but if it's annoying to you, you can configure git to open vim with a different layout by setting the `mergetool.vimdiff.layout` option (see `man git-mergetool` for details ).

For simple diffs or some pull request reviews, I just use `git diff` and sometimes, if the diff is large, I'll pipe that into vim (if you have syntax enabled, the diff output will be colorized, and having the diff in vim can make reading large but monotonous pull requests easier)

For more complex changes or when I expect I may want to update a file (such as when checking my changes before committing), I'll use `git difftool` (with vimdiff as the difftool).

vim's diff mode is pretty good. I'd recommend reading `:help diff` before skipping it (and maybe `:help windows` if the multiple panes are bugging you)

most times I just open two splits, paste the contents in each, and visually grok, which you can imagine is time consuming and not very efficient.

Running `:diffthis` in each split will show the diff in vim. You may wish to write your own command to handle the whole "new split, paste contents, diff" process (see`:help :DiffOrig` for a sample command you can add to your vimrc which is similar)

🐙 norayr · Apr 26 at 00:24:

and i prefer tkdiff. (:

☕️ Morgan · Apr 27 at 04:35:

vimdiff sounds like the same UI concept as kdiff3, good to know :) thanks.