brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: git difftool --dir-diff opens all changed files in one diff window

Git
~/tips/tip-git-difftool-dir-diff

git difftool --dir-diff

Opens your visual diff tool once with two folders to compare, instead of once per changed file.

By default git difftool opens your diff tool once for every changed file and asks first. With ten changed files that gets old by file three. There’s a flag that fixes it.

git difftool --dir-diff

Short form -d. Git puts the old versions in one temporary folder and the new ones in another, then starts the tool a single time with those two folders. Tools like Meld, Beyond Compare or Kaleidoscope can show a file tree and let you click through.

It works with the same arguments as git diff:

git difftool -d HEAD~3
git difftool -d main...feature

With a small wrapper script as the tool that only prints the two folder names, the right-hand folder holds a symbolic link to the working-tree file for a changed README. That’s the default on Linux and macOS when the right side matches the file on disk, and it means edits you make in the tool land in your real file. If you’d rather not, --no-symlinks copies the files instead. The same listing then shows plain files. On Windows, copying is the default.

The caveat: the diff tool must understand folders. If yours only compares two files, you’ll get an error or a confusing result. You can set the tool once with git config --global diff.tool meld (use your own tool’s name) and skip the prompt with --no-prompt.

Further reading: git-difftool documentation

More Git tips git show-branch main feature git log --stat -5 git merge --no-ff feature -m "Merge feature" git merge --squash feature git merge --abort All Git tips (144) All topics

Link