Git Diff History Navigator Tool (gitdiffnavtool)
History
I was doing a lot of "software archeology" on a repository to see what had changed
in various different commits into the code base. I looked around for a tool that would help
me do that, but didn't find one that did things in a way I found useful. So I wrote one.
It's a "Textual User Interface", meaning that it's designed to be run in a terminal window.
For now, you'll have to run pip install the libraries that are needed and run it in
whatever python environment you need.
I hope it helps you.
Overview
The Git Diff History Navigator Tool is a terminal Textual TUI that provides a multi-pane view for
- browsing a filesystem tree,
- viewing the git history for a selected file, and
- exploring diffs and opening file contents at selected commits.
Depending on layout, panes include file lists, file/repo history lists, a diff view, and an open-file view.
Type q or Q to exit the program.
Key features
Arrow keys move up and down the various columns.
Left and Right arrow keys perform differently in each column.
Implementation notes
- Language: Python 3.14
- UI: Textual (ListView, ListItem, Label, ModalScreen)
- Git integration:
git CLI is used for all git operations and cached for speed.
- Data model: ListItems have attached metadata attributes
_filename, _hash, _repo_status, and _raw_text for robust lookups and reliable UI updates.
Running
Run the application as follows:
gitdiffnavtool.py [options] [path]
path is optional — it defaults to the current working directory. If a filename is provided, the app will open its directory and populate the History column for that file on startup.
Configuration
You can set defaults in .gitdiffnavtool.ini (current directory or $HOME) under [gitdiffnavtool].
Example (comprehensive configuration with all available options):
[gitdiffnavtool]
# Display width for short commit hashes (default: 12, must be >= 1)
hash-length = 12
# Show author name and email in commit rows (default: true)
add-authors = true
# Color scheme for diffs: red-green, blue-orange, teal-purple, style, none (default: style)
color = style
# Diff variant: classic, ignore-spaces, patience, word-diff, side-by-side (default: classic)
diff = classic
# Unified diff context lines (git diff -U; default: 3, must be >= 0)
unified-context = 3
# Minimum terminal width for side-by-side view (default: 60, must be >= 1)
# If terminal width is less than this, side-by-side falls back to unified format
minimum-sidebyside-width = 60
# Start in repository mode instead of file-first mode (default: false)
repo-first = false
# Show startup welcome popup (default: true)
initial-popup = true
# Include ignored files in file lists (default: true)
ignored-files = true
# Include untracked files in file lists (default: true)
untracked-files = true
# Maximum history entries to display (default: 0 = unlimited)
history-limit = 0
# Directory where snapshot files are written (optional, default: beside source file)
# write-output-directory = /tmp/snapshots
# Include commit timestamp in snapshot filenames when using w/W key (default: false)
write-adds-timestamps = false
# Number of hash characters used in snapshot filenames (0 means full hash; default: 12)
write-hash-length = 12
# Reset mtime of snapshot files to commit timestamp (default: true)
write-uses-mtime = true
# Use a specific git branch (optional, default: current branch)
# branch = main
# Enable debug logging to a file (optional, default: disabled)
# debug = /tmp/gitdiffnavtool.log
# Verbosity level equivalent to repeating -v (default: 0)
verbose = 0
# Truncate debug log before writing (default: false / append mode)
trim-debug = false
Command-line and Configuration Options
- All configuration values can be specified on the command line as well (use
--help to see all options).
- Command-line options override configuration file values.
- Boolean options have
--no- variations (e.g., --no-add-authors to disable author display).
Key Options:
--color SCHEME: Set diff colorization (red-green, blue-orange, teal-purple, style, none).
-C or --no-color: Disable diff colorization.
--hash-length N: Display short commit hashes using N characters (default: 12).
--unified-context N: Use N lines of context in diffs (default: 3, minimum 0).
--minimum-sidebyside-width N: Minimum terminal width before side-by-side falls back to unified (default: 60).
--no-add-authors: Hide author name and email in commit rows.
--write-output-directory DIR: Directory where snapshot files are written (default: beside source file).
--blank-before-hunk: Insert a blank line before each diff hunk header (lines starting with @@).
--show-help: Display the help screen and exit.
--show-initial-popup: Display the startup popup and exit.
--init-config [cwd|home]: Write a commented .gitdiffnavtool.ini template and exit (default location: cwd).
Some of the Options
If --hash-length N is provided, displayed short commit hashes will use N characters.
If --unified-context N is provided, diffs will use N lines of context (git diff -U option, default 3, minimum 0).
If --write-output-directory DIR is provided, all snapshot files will be written to that directory (created if it doesn't exist).
The command line options override the config values.
Dependencies
- Required python libraries:
textual, rich.
Troubleshooting
- If the app shows no git history for a file, confirm the file is inside a git repo and that
git is available on PATH.
Source
Main program: gitdiffnavtool.py
License
Apache Version 2.0