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 (1)

Collapse
 
jjjjcccjjf profile image
endan • Edited

Excellent. Just what I needed.