Skip to content

yotsuda/GitDrive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitDrive

PowerShell NavigationCmdletProvider for Git branch navigation and analysis.

Browse branches with cd/ls, view commit diffs with Get-Content, checkout with Invoke-Item, and analyze branches with PowerShell pipelines.

Quick Start

# Navigate to any git repository and mount
cd C:\MyRepo
gcd                          # mounts Git:\ and navigates to current branch

# Browse
dir                          # branches + commits
cd feature\login             # enter a child branch
Get-Content .\abc1234        # view commit diff
cd ..                        # back to parent
ii .\feature\login           # git checkout

Installation

Run the following in a PowerShell 7 console:

Install-PSResource GitDrive

Requires:

  • PowerShell 7.4+
  • .NET 8.0 SDK (for building)

Drive Structure

Git:\
  master                     # root branch (main or master)

Git:\master\
  feature/                   # namespace folder (groups feature/* branches)
  hotfix/                    # namespace folder
  bugfix-test                # child branch
  abc1234                    # commit (leaf)
  def5678                    # commit

Git:\master\feature\
  login                      # branch feature/login
  signup                     # branch feature/signup

Git:\master\feature\login\
  abc1234                    # commit unique to this branch
  def5678                    # commit unique to this branch
  • Branches = containers (blue, cd into them)
  • Commits = leaves (yellow SHA, view with Get-Content)
  • Namespace folders = virtual grouping for /-containing branch names

Commands

Navigation

Command Description
gcd Mount drive and navigate to current branch
gcd feature/login Mount and navigate to specific branch
gcd abc1234 Mount and navigate to specific commit
dir List child branches + commits
dir -Recurse Show full branch hierarchy (no commits)
cd feature\login Enter child branch
cd .. Go up

Branch Operations

Command Description
New-Item .\new-branch -Value master Create branch from master
Remove-Item .\old-branch -Recurse Delete branch
Rename-Item .\old -NewName new Rename branch
Invoke-Item .\feature\login Checkout branch (git checkout)

Viewing

Command Description
Get-Content .\abc1234 Show commit diff/patch
Get-Item .\feature\login Branch details
Get-Item .\abc1234 Commit details

Table Columns

Column Description
Name Branch name (blue) or commit SHA (yellow)
Ahead Commits ahead of parent branch (+5)
Date Commit/tip date
Author Commit/tip author
Message Commit/tip message
Refs Branches, tags, HEAD -> pointing to this commit

Current branch is marked with *. Namespace folders show branch count.

Pipeline Analysis

GitDrive outputs typed objects, enabling PowerShell pipeline operations that are difficult with git CLI.

Find merged branches

Get-ChildItem -Recurse |
  Where-Object { $_.IsBranch -and $_.Ahead -eq 0 -and -not $_.IsCurrent }

Find stale branches (older than 3 months)

Get-ChildItem -Recurse |
  Where-Object { $_.IsBranch -and $_.Date -lt (Get-Date).AddMonths(-3) } |
  Sort-Object Date

Top 5 branches by commit count

Get-ChildItem -Recurse |
  Where-Object IsBranch |
  Sort-Object Ahead -Descending |
  Select-Object -First 5 Name, Ahead

Find branches by author

Get-ChildItem -Recurse |
  Where-Object { $_.IsBranch -and $_.Author -match 'yotsuda' }

Branch health summary

$b = Get-ChildItem -Recurse | Where-Object IsBranch
[PSCustomObject]@{
    Total   = $b.Count
    Merged  = ($b | Where-Object { $_.Ahead -eq 0 }).Count
    Stale   = ($b | Where-Object { $_.Date -lt (Get-Date).AddMonths(-3) }).Count
    Active  = ($b | Where-Object { $_.Date -gt (Get-Date).AddMonths(-1) }).Count
}

Compare two branches

$master  = Get-ChildItem Git:\master | Where-Object { -not $_.IsBranch }
$feature = Get-ChildItem Git:\master\feature\login
Compare-Object $master $feature -Property Sha -PassThru |
  Select-Object @{N='Side';E={$_.SideIndicator}}, @{N='Sha';E={$_.ShortSha}}, ShortMessage

Clean up merged branches

Get-ChildItem -Recurse |
  Where-Object { $_.IsBranch -and $_.Ahead -eq 0 -and -not $_.IsCurrent } |
  Remove-Item -Recurse

Object Properties

Items output by Get-ChildItem are GitCommitInfo objects with these properties:

Property Type Description
Name string Branch name or short SHA
Sha string Full commit SHA
Message string Commit message
Author string Author name
Date DateTime Author date
Ahead int Commits ahead of parent (branches only)
Refs string Branches/tags pointing to this commit
IsBranch bool True for branches
IsNamespace bool True for namespace folders
IsCurrent bool True for checked-out branch
ShortSha string 7-char SHA
ShortMessage string First line of message
DateStr string yyyy-MM-dd format

Performance

Operation First Cached
dir (root) 0.02s 0.02s
dir (39 branches) 1.0s 0.3s
dir -Recurse (39 branches) 14s 0.5s

Cache TTL is 30 seconds. Invalidated automatically after create/delete/rename.

About

Navigate Git branches as a PowerShell PSDrive. Browse, compare, and manage branches with cd/ls and pipeline analysis.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors