Timoch Git Stats for VS Code
A VS Code extension that displays git repository statistics in the status bar, including line counts and change tracking. Based on the functionality of a bash git prompt script.
Features
- Line Counting: Shows total lines of code in your project with smart filtering
- Git Branch Display: Shows current git branch in the status bar
- Branch Statistics: Displays lines added/removed since branching from main/master
- Working Changes: Shows uncommitted changes (staged, unstaged, and untracked files)
- Smart Caching: Efficient performance with intelligent cache invalidation
- Fully Customizable: Configure file patterns, update intervals, and display options
Status Bar Display
The extension shows information in the following format:
🔀 branch-name 📄 15.2K +120/-45 [+30/-10]
Where:
branch-name : Current git branch
15.2K : Total lines in the project (formatted with K/M suffixes)
+120/-45 : Lines added/removed in commits since branching from main/master
[+30/-10] : Uncommitted changes (staged + unstaged + untracked)
Installation
From VSIX Package
code --install-extension timoch-git-stats-1.0.0.vsix
From Source
- Clone the repository
- Run
npm install to install dependencies
- Run
npm run compile to build the extension
- Press
F5 in VS Code to launch a new Extension Development Host window
Configuration
Configure the extension through VS Code settings (File → Preferences → Settings, then search for "Git Stats"):
Basic Settings
gitStats.enabled (boolean, default: true )
- Enable or disable the Git Stats extension
gitStats.updateInterval (number, default: 5000 )
- Update interval in milliseconds (minimum 1000)
- Lower values update more frequently but use more resources
gitStats.showBranchStats (boolean, default: true )
- Show lines added/removed since branching from main/master
gitStats.showWorkingChanges (boolean, default: true )
- Show uncommitted changes in brackets [+X/-Y]
File Filtering
Configuration Examples
Example 1: Exclude additional directories
{
"gitStats.excludePatterns": [
"**/node_modules/**",
"**/bin/**",
"**/obj/**",
"**/dist/**",
"**/build/**",
"**/*.min.*",
"**/package-lock.json",
"**/vendor/**", // PHP vendor directory
"**/.next/**", // Next.js build directory
"**/target/**", // Rust/Java build directory
"**/__pycache__/**" // Python cache
]
}
Example 2: Include only specific languages
{
"gitStats.includeExtensions": [
"ts", "tsx", "js", "jsx", // TypeScript/JavaScript only
"json", "md" // Plus config and docs
]
}
Example 3: Fast updates for active development
{
"gitStats.updateInterval": 2000, // Update every 2 seconds
"gitStats.showWorkingChanges": true,
"gitStats.showBranchStats": true
}
Commands
Access commands through the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
Default File Filters
Included Extensions
- Programming:
cs , ts , tsx , js , jsx , py , java , cpp , c , h , hpp , go , rs , rb , php , swift , kt , scala , r , sql
- Markup/Config:
json , xml , yaml , yml , html , css , scss , md , txt
- Scripts:
sh , ps1 , psm1 , psd1
- Project files:
csproj , sln , razor
- Special files without extensions:
Dockerfile , Makefile , Rakefile , Gemfile , Vagrantfile , Jenkinsfile , Procfile
Default Excluded Patterns
- Build outputs:
**/bin/** , **/obj/** , **/dist/** , **/build/**
- Dependencies:
**/node_modules/**
- Minified files:
**/*.min.*
- Lock files:
**/package-lock.json
- CDK outputs:
**/cdk.out/** , **/.cdk.staging/** , **/cdk.context.json
- Claude AI:
**/.claude/**
Troubleshooting
Line count seems incorrect
- Check your exclude patterns in settings
- Use
Git Stats: Show Detailed Statistics to see what's being counted
- Run
Git Stats: Clear Cache to force a recount
Extension not showing in status bar
- Ensure you're in a git repository
- Check that
gitStats.enabled is true in settings
- Try running
Git Stats: Refresh Statistics
- Increase
gitStats.updateInterval (e.g., to 10000 for 10-second updates)
- Add more specific exclude patterns for large directories
- The extension uses caching, so performance should improve after initial scan
Development
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch for changes
npm run watch
# Run linter
npm run lint
# Package extension
npm install -g @vscode/vsce
vsce package
License
MIT
| |