A dev tool that analyzes a git branch history and visualizes how the line counts
of selected file types (e.g. *.js, *.scss) change over time, rendered as an
interactive browser chart. Requires Node.js 20 or newer.
Install as a dev dependency (recommended) and run it with npx:
npm install -D git-line-visualizerA local install is recommended over a global one (
npm i -g). The CLI command isgitline, a name other globally-installed packages might also use; installing locally keeps the command isolated to your project'snode_modules/.binand avoids any conflict.
Run it from the root of the target project (a git repository):
npx gitlineYour default browser opens automatically with the time-series chart.
| Option | Default | Description |
|---|---|---|
--dir <path> |
src |
Directory to analyze |
--branch <name> |
detected (see below) | Branch to analyze |
--ext <list> |
js,scss |
Comma-separated file extensions |
--port <number> |
4711 |
Local server port |
When --branch is omitted, the branch is detected from the repository: the
remote's default branch (origin/HEAD), else a local main or master, else
whatever is currently checked out.
You can also configure these via the gitline field in the target project's
package.json (CLI arguments take precedence):
{
"gitline": {
"dir": "src",
"ext": "js,scss",
"port": 4711
}
}Examples:
# Track TypeScript and CSS on the develop branch
npx gitline --ext ts,tsx,css --branch develop
# Analyze a different directory on a custom port
npx gitline --dir packages/web/src --port 5050- Load the
.gitline-cache.jsoncache. - List commits via
git log <branch>. - Analyze only newly-seen commits (incremental). Each batch of commits is read
through a single
git cat-file --batchcall rather than one git process per file, and line counts are cached per blob SHA, so files unchanged between commits are counted only once. The cache accumulates across branches — switching frommaintodevelop(and back) only analyzes commits not seen before. Changing the extension set recomputes per-commit totals, but the blob cache survives, so only files never seen before are read again. - Update the cache.
- Start a local http server and open the browser.
- Render the per-extension line-count chart with ECharts, served from the installed package so the chart works with no internet access.
The chart shows one line series per configured extension. Use zoom/scroll to
navigate, and click a commit point to see its full hash, message, author, date,
and per-extension line counts (with the delta vs. the previous commit) in the
side panel. Navigate between commits with the left/right arrow keys, copy the
full hash from the detail panel, switch between dark and light themes, and
toggle alternating month background bands — all from the header. Theme and
month-shading preferences are persisted to localStorage.
Add
.gitline-cache.jsonto your.gitignore.