param( [string]$Message = "" ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot $git = "C:\Program Files\Git\cmd\git.exe" if (-not (Test-Path $git)) { throw "git.exe was not found at $git" } $branch = (& $git -C $repoRoot branch --show-current).Trim() if (-not $branch) { throw "No active git branch was found." } $status = & $git -C $repoRoot status --porcelain if (-not $status) { Write-Host "No changes to sync." exit 0 } if (-not $Message) { $Message = "Permanent memory sync $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" } & $git -C $repoRoot add -A & $git -C $repoRoot commit -m $Message & $git -C $repoRoot push origin $branch Write-Host "Synced branch '$branch' to origin."