Skip to content

Latest commit

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date

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 branchGet-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

CommandDescription
gcdMount drive and navigate to current branch
gcd feature/loginMount and navigate to specific branch
gcd abc1234Mount and navigate to specific commit
dirList child branches + commits
dir -RecurseShow full branch hierarchy (no commits)
cd feature\loginEnter child branch
cd ..Go up

Branch Operations

CommandDescription
New-Item .\new-branch -Value masterCreate branch from master
Remove-Item .\old-branch -RecurseDelete branch
Rename-Item .\old -NewName newRename branch
Invoke-Item .\feature\loginCheckout branch (git checkout)

Viewing

CommandDescription
Get-Content .\abc1234Show commit diff/patch
Get-Item .\feature\loginBranch details
Get-Item .\abc1234Commit details

Table Columns

ColumnDescription
NameBranch name (blue) or commit SHA (yellow)
AheadCommits ahead of parent branch (+5)
DateCommit/tip date
AuthorCommit/tip author
MessageCommit/tip message
RefsBranches, 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-eq0-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.CountMerged= ($b|Where-Object { $_.Ahead-eq0 }).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-eq0-and-not$_.IsCurrent } |Remove-Item-Recurse

Object Properties

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

PropertyTypeDescription
NamestringBranch name or short SHA
ShastringFull commit SHA
MessagestringCommit message
AuthorstringAuthor name
DateDateTimeAuthor date
AheadintCommits ahead of parent (branches only)
RefsstringBranches/tags pointing to this commit
IsBranchboolTrue for branches
IsNamespaceboolTrue for namespace folders
IsCurrentboolTrue for checked-out branch
ShortShastring7-char SHA
ShortMessagestringFirst line of message
DateStrstringyyyy-MM-dd format

Performance

OperationFirstCached
dir (root)0.02s0.02s
dir (39 branches)1.0s0.3s
dir -Recurse (39 branches)14s0.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

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages