# Sync script to keep origin and upstream remotes in sync # Usage: .\sync_remotes.ps1 [--push-to-origin] param( [switch]$PushToOrigin ) $ErrorActionPreference = "Stop" $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path $repoRoot = Split-Path -Parent (Split-Path -Parent $scriptPath) Write-Host "šŸ”„ WebDrop Bridge - Remote Sync Script" -ForegroundColor Cyan Write-Host "Repository: $repoRoot`n" -ForegroundColor Gray # Change to repo directory Push-Location $repoRoot try { # Fetch from both remotes Write-Host "šŸ“„ Fetching from origin..." -ForegroundColor Yellow git fetch origin Write-Host "šŸ“„ Fetching from upstream..." -ForegroundColor Yellow git fetch upstream # Show status Write-Host "`nšŸ“Š Remote Status:" -ForegroundColor Cyan git remote -v # Show branch comparison Write-Host "`nšŸ“‹ Branch Comparison:" -ForegroundColor Cyan Write-Host "Local branches vs origin:" -ForegroundColor Gray git log --oneline origin/main -5 | ForEach-Object { Write-Host " origin: $_" } Write-Host "" git log --oneline upstream/main -5 | ForEach-Object { Write-Host " upstream: $_" } # Optionally push to origin if ($PushToOrigin) { Write-Host "`nšŸ“¤ Pushing current branch to origin..." -ForegroundColor Yellow $currentBranch = git rev-parse --abbrev-ref HEAD git push origin $currentBranch Write-Host "āœ… Pushed $currentBranch to origin" -ForegroundColor Green } else { Write-Host "`nšŸ’” Tip: Use --push-to-origin flag to push current branch to origin" -ForegroundColor Gray } Write-Host "`nāœ… Sync complete!" -ForegroundColor Green } catch { Write-Host "`nāŒ Error: $_" -ForegroundColor Red exit 1 } finally { Pop-Location }