Skip to content

masukomi/cleandiff

Repository files navigation

Readme

CleanDiff

A cleaner way to diff files that’s easier on your 🧠.

Cleandiff helps you focus on the specific changes, without unnecessary noise.

Installation

Homebrew (macOS/Linux)

brew tap masukomi/homebrew-tap
brew install masukomi/homebrew-tap/cleandiff

From Source

Prerequisites

Install the Wails CLI with:

go install github.com/wailsapp/wails/v2/cmd/wails@latest

Building

git clone https://github.com/masukomi/cleandiff.git
cd cleandiff
cd frontend && npm install && cd ..
wails build

The built application will be in build/bin/:

  • macOS: build/bin/cdiff.app (with CLI at cdiff.app/Contents/MacOS/cdiff)
  • Linux: build/bin/cdiff

Add the cdiff executable to your PATH to use it from the command line.

Configuration

Git

First, let’s add cdiff as a new difftool

git config --global difftool.cdiff.cmd 'cdiff "$LOCAL" "$REMOTE" "$MERGED"'

Next, let’s add an alias so that we can just say git cdiff <diff options> instead of having to type git difftool --tool=cdiff <diff options>

git config --global alias.cdiff "difftool --tool=cdiff"

Optional If you want to make it your default difftool you can run the following command. While I use it regularly, sometimes traditional diffing tools are the right choice.

git config --global diff.tool cdiff

Usage

Invoking it

With git diffs

Assuming you’ve configured things as described above, invocation is exactly the same as with git diff, you just say git cdiff instead.

For example, to see what changes have been added in “branch_b” you could run either of the following.

git cdiff main..branch_b
git difftool --tool=cdiff main..branch_b

Diffing random files

cdiff takes 3 options

  • original file
  • changed file
  • (optional) file name

The file name is what’s displayed both at the top of the page, and in Cleandiff’s sidebar.

cdiff original_file.txt changed_version.txt
cdiff original_file.txt changed_version.txt "the_memo"

Getting More Context

You’ll notice that Cleandiff focuses on not just the words that have changed, but also the lines. By default it shows you a handful of lines around the changes; just enough to give you context for the change. Sometimes, you need a little more.

Cleandiff gives you two options for this.

Usually - if any more context is needed - you only need a few more lines to understand the change. Clicking any of the line numbers near a jump will expand 10 lines above it. You can repeat as needed.

A screenshot of the same before and after clicking a line number to expand the context

Alternately, if you just want to see everything you can click the eye icon at the top of the page will show you the entire file, by toggling the visibility of all the hidden liens.

A screenshot of the eye icon next to the filename with an arrow pointing to it.

About

CleanDiff is a better diffing tool, that's easier on your brain.

Resources

License

Stars

Watchers

Forks