DEV Community

Yuji Ueki
Yuji Ueki

Posted on

πŸ” difit: Preview GitHub-like diffs locally before you push

πŸ“ This is a short introduction to difit β€” a tiny CLI tool that lets you preview Git diffs in a GitHub-style interface, right from your local machine, with no installation required.


πŸ€” Ever wish you could preview your GitHub diff before you push?

You're working on a feature, writing commits one by one.

Before opening a pull request, you want to double-check your changesβ€”

But git diff in the terminal is messy, and pushing just to preview the PR feels wasteful.

Enter difit: a lightweight CLI tool that lets you see your Git changes in a GitHub-like diff view, right in your browser β€” locally.


πŸš€ What is difit?

difit launches a local web UI that mimics GitHub’s diff view, showing you a full side-by-side comparison of your Git changes β€” all from a single command.

You don’t even need to install anything.


⚑ Quick start (no install needed)

You can run difit instantly using npx:

npx difit
Enter fullscreen mode Exit fullscreen mode

This will:

  • Launch a local server
  • Open your browser
  • Show a visual diff between your current working tree and the last commit

πŸ–Ό Example screenshot

difit_preview

Looks just like GitHub, right?

🧩 File-by-file diff
🌈 Syntax highlighting
πŸ“„ Foldable sections
🧘 Clean UI for peaceful reviews


πŸ”§ Other usage examples

Show staged & unstaged changes (default)

npx difit
Enter fullscreen mode Exit fullscreen mode

Compare against another branch (e.g. main)

npx difit origin/main
Enter fullscreen mode Exit fullscreen mode

Compare two commits explicitly

npx difit abc123..def456
Enter fullscreen mode Exit fullscreen mode

Compare current changes

npx difit          # HEAD commit changes
npx difit .        # All uncommitted changes (staged + unstaged)
npx difit staged   # Staged changes ready for commit
npx difit working  # Unstaged changes only (cannot use compare-with)
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Why use difit?

πŸ” Preview before pushing

See what your PR will look like before opening it.

🧼 Spot mistakes early

Catch debug logs, leftover TODOs, or secret keys before they go public.

πŸ“‹ Review your own work visually

Especially helpful before pushing large commits or squashed branches.

β›” Avoid pushing just to review

No need to create throwaway PRs just to read a diff.

πŸ’» Works offline

No GitHub token, no auth, no internet required.


πŸ™‹β€β™‚οΈ About the author

difit is developed by @yoshiko_pg, who creates practical and elegant dev tools with minimalism and clarity in mind.

Check out the project here:
πŸ”— https://github.com/yoshiko-pg/difit


πŸ§ͺ Final thoughts

GitHub’s diff viewer is great β€” but it’s gated behind a push.
difit removes that barrier.

Now you can review your code visually before it ever leaves your machine.

Give it a try. Just one command:

npx difit
Enter fullscreen mode Exit fullscreen mode

And you’re reviewing like it’s already a PR ✨

Top comments (0)