Skip to main content

Beautiful git viewer in your browser like GitHub, but local. Diffs, history, blame, compare branches/SHAs, contributors, and more.

Project description

git-diff ๐Ÿ”

Beautiful git viewer in your browser like GitHub, but local and instant.
No tokens. No accounts. No internet. Just git-diff and a browser tab.

PyPI version Python 3.8+ License: MIT CI Zero dependencies


The problem

$ git diff HEAD~3
diff --git a/src/api/users.py b/src/api/users.py
index 3f2a1b8..9c4d72e 100644
--- a/src/api/users.py
+++ b/src/api/users.py
@@ -142,6 +142,9 @@ class UserService:
...

Raw git diff in a terminal is painful no syntax colors that actually help, no side-by-side view, no file navigation, no history, no blame. You have to mentally parse it line by line.

git-diff opens a GitHub-quality interface in your browser right now, from any repo, with no setup.


Install

pip install git-diff

That's it. No npm, no node, no extra deps.


Usage

# Open viewer for the current repo
cd /path/to/your/project
git-diff

# Specify a repo path
git-diff --path /path/to/repo

# Use a custom port
git-diff --port 8080

# Bind to all interfaces (share on LAN)
git-diff --host 0.0.0.0

# Don't auto-open browser (print URL only)
git-diff --no-browser

# Show 5 lines of context in diffs
git-diff --context 5

# Print version
git-diff --version

A browser tab opens automatically at http://127.0.0.1:7433.


Features

๐Ÿ”€ Diff Viewer (GitHub-style)

  • Line-by-line diff with line numbers, color-coded + additions / - deletions
  • Hunk headers showing function/class context (@@ ... @@ def my_function)
  • File status badges Added, Modified, Deleted, Renamed (with similarity %)
  • Collapsible files click any file header to expand/collapse
  • Binary file detection
  • Support for thousands of changed files in a single view

๐Ÿ“Š Repository Overview

  • Total commits, contributors, files, branches, tags, repo size
  • Commit activity heatmap (last 90 days, GitHub-style calendar)
  • Language breakdown files and percentage by extension with color chart

๐Ÿ“œ Commit History

  • Browse all commits with author, date, relative time ("3 hours ago")
  • Click any commit to see its full diff instantly
  • Merge commit detection
  • Parent commit links (click to navigate)
  • Ref decoration branch labels, HEAD pointer, tags
  • Search and filter commits in the sidebar

๐Ÿ”€ Compare Any Two Refs

  • Compare any branch vs branch, tag vs tag, SHA vs SHA, or any mix
  • Shows all commits in the range + full file diff
  • One-click "Diff vs current" button on every branch in the branches panel
  • Keyboard shortcut: Ctrl/Cmd + K

โœ๏ธ Working Tree Changes

  • Staged and Unstaged changes clearly separated
  • Click any file in sidebar to jump to its specific diff
  • Real-time (refresh to update)

๐Ÿ“ File Browser

  • Browse all tracked files
  • View file content with syntax-aware line numbers
  • File history all commits that touched a file
  • Blame view who wrote which line, with commit hash and date
  • Filter by filename in sidebar

๐Ÿ‘ฅ Contributors

  • Ranked leaderboard by commit count
  • Visual progress bars
  • Email address, commit count

๐ŸŒฟ Branches & Tags

  • All local and remote branches
  • Tags with dates and annotation messages
  • "Diff vs current" button on every branch

๐Ÿ“ฆ Stashes

  • View all stashed changes
  • Click to see full diff for any stash entry

๐ŸŽจ 3 Themes

Theme Description
๐ŸŒ™ Dark GitHub dark easy on the eyes
โ˜€๏ธ Light GitHub light clean and crisp
โšซ AMOLED True black perfect for OLED screens

Themes are persisted in localStorage your preference sticks across sessions.

โŒจ๏ธ Keyboard Shortcuts

Shortcut Action
Esc Return to overview
Ctrl/Cmd + R Refresh repository data
Ctrl/Cmd + K Open Compare view
Ctrl/Cmd + \ Toggle sidebar

How it works

git-diff is a single Python package with zero runtime dependencies. It:

  1. Detects your git repository root (walks up from CWD)
  2. Collects all data by running git subprocess commands
  3. Starts a tiny HTTP server using Python's built-in http.server
  4. Serves a single-page web app with full UI
  5. Opens your browser automatically
  6. Exposes a /api/* REST endpoint for on-demand data

Everything runs 100% locally. No data leaves your machine.


API Reference

git-diff exposes these endpoints (accessible at http://127.0.0.1:7433):

Endpoint Description
GET / The web UI
GET /api/data Full initial data bundle (repo info, commits, diffs, etc.)
GET /api/commit?hash=<sha> Commit diff + detail for a specific SHA
GET /api/commits?branch=&limit=&offset=&search=&author= Paginated commit history
GET /api/staged[?context=N] Current staged diff
GET /api/unstaged[?context=N] Current unstaged diff
GET /api/range-diff?base=<ref>&compare=<ref> Diff between any two refs
GET /api/file?path=<path>[&ref=<ref>] File content at a ref
GET /api/file-log?path=<path>[&limit=N] Commit history for a file
GET /api/blame?path=<path>[&ref=<ref>] Blame for a file
GET /api/stash?ref=<stash-ref> Stash diff
GET /api/activity[?days=N] Commit activity by day
GET /api/langs Language statistics
GET /api/refresh Re-collect all data
GET /api/git?cmd=<git-args> Safe read-only git passthrough

Supported git commands (internal)

git-diff internally uses these git operations to collect data:

git rev-parse          detect repo root, resolve refs
git log                commit history, activity stats, file history
git show               commit detail, file content at ref
git diff               staged, unstaged, commit diffs
git status             working tree status
git blame              line-level authorship
git stash list/show    stash entries and diffs
git branch             local and remote branches
git for-each-ref       tags with metadata
git shortlog           contributor stats
git ls-tree            tracked file listing
git remote             remote URLs
git rev-list           commit counts

Supported Platforms

Platform Status
macOS (10.14+) โœ… Fully supported
Linux (Ubuntu, Debian, Fedora, Archโ€ฆ) โœ… Fully supported
Windows 10/11 โœ… Fully supported
Python 3.8 โ€“ 3.13 โœ… Tested via CI

Development

# Clone the repo
git clone https://github.com/ankit-chaubey/git-diff.git
cd git-diff

# Install in editable mode
pip install -e .

# Run on itself great for testing!
git-diff

Project structure

git-diff/
โ”œโ”€โ”€ git_diff/
โ”‚   โ”œโ”€โ”€ __init__.py         Package metadata (version, author)
โ”‚   โ”œโ”€โ”€ __main__.py         python -m git_diff support
โ”‚   โ”œโ”€โ”€ cli.py              Argument parsing, startup banner
โ”‚   โ”œโ”€โ”€ git_data.py         All git data collection (subprocess calls)
โ”‚   โ”œโ”€โ”€ server.py           HTTP server + REST API endpoints
โ”‚   โ””โ”€โ”€ templates/
โ”‚       โ””โ”€โ”€ index.html      Full single-page web app (HTML + CSS + JS)
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ”œโ”€โ”€ publish.yml     PyPI trusted publisher (OIDC)
โ”‚       โ””โ”€โ”€ ci.yml          CI: test on 3 OS ร— 5 Python versions
โ”œโ”€โ”€ pyproject.toml          PEP 517 build config
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ CHANGELOG.md
โ””โ”€โ”€ LICENSE                 MIT

Changelog

See CHANGELOG.md.


License

MIT ยฉ 2024-Persent Ankit Chaubey


Author

Ankit Chaubey
๐Ÿ“ง ankitchaubey.dev@gmail.com
๐Ÿ™ github.com/ankit-chaubey


Made with โค๏ธ because raw git diff in terminal hurts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_diff-0.1.4.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_diff-0.1.4-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file git_diff-0.1.4.tar.gz.

File metadata

  • Download URL: git_diff-0.1.4.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_diff-0.1.4.tar.gz
Algorithm Hash digest
SHA256 3cab031366886e4d68359f87a210b0168fdb8f8d73c212cd848c807a5ea6b35f
MD5 52343d94984d5f4705ed9926aaec0626
BLAKE2b-256 d6cc8f4bb1cfcb17deeb2c56bc1579f02299c269edd2447ba62b136adc817448

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_diff-0.1.4.tar.gz:

Publisher: publish.yml on ankit-chaubey/git-diff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_diff-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: git_diff-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_diff-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f328a8a048f0ea1b11f887aa90dd6d768ba2096607d3b8b2908c76d6fb2e9b3e
MD5 b6eda4f60eebdc57f5ff9c283c0967a1
BLAKE2b-256 5d5363ef0d88c8e1d5e6e0a05b1976f529dacee3d92e98b05705bab77b27406d

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_diff-0.1.4-py3-none-any.whl:

Publisher: publish.yml on ankit-chaubey/git-diff

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page