Git

2.1.0

Common Git workflow helpers: branch maintenance, tagging, and repository synchronization.

Minimum PowerShell version

5.1

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Module -Name Git -RequiredVersion 2.1.0

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

Install-PSResource -Name Git -Version 2.1.0

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

(c) 2026 mtb.me. All rights reserved.

Package Details

Author(s)

  • Manuel

Tags

Git Branch Tag Workflow PowerShell Windows

Functions

Add-AssumedUnchanged Add-GitTag Clear-GitBranches Invoke-Gitk Invoke-GitkAll Merge-GitAllRemoteBranches Merge-GitBranchUseTheirs Push-GitAllTrackedBranches Remove-AssumedUnchanged Remove-GitAllBranches Reset-GitAllBranches Set-GitTrackAllRemoteBranches Set-GitTrackMatchedRemoteBranches Update-GitAllBranches Update-GitBranch

PSEditions

Desktop Core

Dependencies

Release Notes

Git v2.1.0+sha.f39ace7

## [v2.1.0] - 2026-05-06

### Added

- `-PassThru` parameter on every multi-item Public function
 (`Update-GitAllBranches`, `Update-GitBranch`,
 `Push-GitAllTrackedBranches`, `Merge-GitAllRemoteBranches`,
 `Merge-GitBranchUseTheirs`, `Remove-GitAllBranches`,
 `Reset-GitAllBranches`, `Set-GitTrackAllRemoteBranches`,
 `Set-GitTrackMatchedRemoteBranches`, `Clear-GitBranches`,
 `Add-AssumedUnchanged`, `Remove-AssumedUnchanged`, `Add-GitTag`).
 Returns `[pscustomobject]` records with shape
 `{ Branch, Action, Result, Reason, Detail }` and `PSTypeName`
 `Git.BranchResult`. Suitable for pipeline consumption and
 Format-view rendering. (#4)
- `Git.Format.ps1xml` providing a default table view for
 `Git.BranchResult` records (Branch / Action / Result / Reason).
 Wired into the manifest via `FormatsToProcess` and copied into
 the build output via `build.psd1`'s `CopyPaths`. (#4)
- `Write-Progress` for long-running multi-branch operations
 (`Update-GitAllBranches`, `Push-GitAllTrackedBranches`,
 `Merge-GitAllRemoteBranches`, `Remove-GitAllBranches`,
 `Clear-GitBranches`, `Set-GitTrackAllRemoteBranches`,
 `Set-GitTrackMatchedRemoteBranches`). Each loop ends with a
 `-Completed` cleanup so partial progress bars do not leak when
 the caller aborts. (#4)
- Internal `-NoRestore` switch on `Remove-GitAllBranches`,
 `Set-GitTrackAllRemoteBranches`, `Merge-GitAllRemoteBranches`,
 `Merge-GitBranchUseTheirs`, `Update-GitAllBranches`,
 `Push-GitAllTrackedBranches`, and
 `Set-GitTrackMatchedRemoteBranches`. Documented as
 "Internal use only" in `.PARAMETER` and used by
 `Reset-GitAllBranches` to consolidate the working-tree
 restoration to a single outer `try/finally`. Not in README. (#4)
- E2E test helpers under `tests/_Helpers/Git-RepoFixture.ps1`
 (`New-TestRepo`, `New-TestCommit`, `New-TestBareRemote`,
 `New-TestTempPath`). Helpers are dot-sourced from individual test
 files and never exported from the module. (#4)

### Changed

- `Update-GitAllBranches`: fast-forward updates use `git update-ref`
 for non-current branches (no working-tree mutation, no checkout).
 The current branch fast-forwards via `git merge --ff-only`.
 Diverged branches still go through `checkout + rebase`.
 Up-to-date branches are silently skipped via `Write-Verbose`.
 Compare-and-swap form (`<oldExpected>` argument) means a
 concurrent push fails the call instead of silently overwriting
 an unrelated tip; on CAS-failure the function falls back to the
 rebase path. (#4)
- `Get-RebasedAndSquashedBranches`: hybrid `git cherry` fast path
 with the existing test-merge fallback. Branches whose patch-ids
 are all absorbed by the current branch resolve at the cherry
 stage; branches with `+` lines fall through to the test-merge so
 the amended-squash edge case (patch-id changes, tree identical)
 still gets caught. ~10-50x faster on typical post-sprint cleanup;
 return type unchanged. (#4)
- `Push-GitAllTrackedBranches`: explicit refspec form
 (`git push <remote> <local>:refs/heads/<remote-branch>`).
 No per-branch checkout; the working tree's HEAD branch never
 changes. (#4)
- `Reset-GitAllBranches`: single outer working-tree restoration.
 Inner functions are called with the new internal `-NoRestore`
 switch so the original HEAD is restored once at the outer
 boundary instead of three times in nested finally blocks. (#4)
- User-facing string formatting: identifier interpolations (branch
 names, paths, refs, SHAs, tags) are consistently wrapped in
 single quotes inside `Write-Verbose` / `Write-Host` /
 `Write-Warning` / `Write-Error` / `Write-Debug` messages.
 Period for completed statements; ASCII three-period ellipsis for
 in-progress. Counts and Activity strings stay unquoted. (#4)

### Changed (BREAKING)

- `Merge-GitBranchUseTheirs`: replaced the temp-branch trick with
 native `git merge -X theirs --no-ff`. **Behaviour change**: files
 added only on `DestinationBranch` are now retained. The legacy
 temp-branch implementation merged the destination into a temp
 branch with `--strategy=ours` and then merged that back, which
 silently discarded destination-only additions. The new behaviour
 matches the documented `-X theirs` semantic and what most "vendor
 merge" workflows actually want. If the strict "exact source-tree"
 semantic is needed, perform the temp-branch dance manually:
 `git checkout -b tmp <source>; git merge --strategy=ours <dest>;
 git checkout <dest>; git merge --no-ff tmp; git branch -D tmp`. (#4)

### Fixed

- `Invoke-Git`: pin `-ErrorAction Continue` at the `Invoke-NativeCommand`
 parameter boundary instead of via a local `$ErrorActionPreference`
 assignment. PowerShell 5.1 wraps native-command stderr lines as
 `RemoteException` error records on the PowerShell error stream;
 under the caller's `$ErrorActionPreference = 'Stop'` those records
 terminate execution even when git itself exited 0 (e.g. `git fetch`
 emitting `From <url>` to stderr, `git push` emitting `To <url>`,
 `git merge --no-commit` emitting `Automatic merge went well`).
 `$ErrorActionPreference` is per-SessionState dynamic-scoped; a local
 variable assignment in the Git module scope never reached the inner
 backend in Execution's scope, so the previous attempt at the fix was
 ineffective. Binding `-ErrorAction` at the parameter level applies
 inside Execution's own scope where the script-block backend reads it.
 Genuine non-zero exits still throw via the wrapper's own raise. (#4)

FileList

Version History

Version Downloads Last updated
2.1.1 15 5/6/2026
2.1.0 (current version) 9 5/6/2026
2.0.0 39 5/6/2026
1.5.0 262 4/25/2026
1.4.2 61,227 5/16/2024
1.4.1 22,218 3/9/2020
1.4.0 132 3/9/2020
1.3.3 494 2/5/2020
1.3.2 2,646 5/9/2019
1.3.1 335 4/4/2019
1.3.0 160 3/29/2019
1.2.0 134 3/28/2019
1.1.0 192 3/18/2019
1.0.1 123 3/17/2019
1.0.0 30 3/17/2019
Show more