From d495296cd8da0d4ff36e46586c23a6cb497ce3a7 Mon Sep 17 00:00:00 2001 From: xudan Date: Mon, 16 Jun 2025 10:39:47 +0800 Subject: [PATCH] Update sync script: remove auto-push and fix encoding issues --- sync-repos.ps1 | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/sync-repos.ps1 b/sync-repos.ps1 index ae9390f..7e97937 100644 --- a/sync-repos.ps1 +++ b/sync-repos.ps1 @@ -1,5 +1,4 @@ # Git Multi-Repository Sync Script (PowerShell) -# For syncing mirror repository to your personal repository param( [switch]$UseRebase = $false, @@ -58,6 +57,7 @@ function Sync-Repositories { git rebase upstream/master if ($LASTEXITCODE -ne 0) { Write-ColorOutput "Rebase failed! Please resolve conflicts manually." "Red" + Write-ColorOutput "After resolving conflicts, run: git rebase --continue" "Yellow" return } } else { @@ -69,6 +69,7 @@ function Sync-Repositories { git merge upstream/master if ($LASTEXITCODE -ne 0) { Write-ColorOutput "Merge failed! Please resolve conflicts manually." "Red" + Write-ColorOutput "After resolving conflicts, run: git commit" "Yellow" return } } else { @@ -76,24 +77,14 @@ function Sync-Repositories { } } - # Push to your repository - Write-ColorOutput "Pushing to your repository..." "Green" - if (-not $DryRun) { - if ($UseRebase) { - git push origin master --force-with-lease - } else { - git push origin master - } - if ($LASTEXITCODE -ne 0) { - Write-ColorOutput "Push failed!" "Red" - return - } - } else { - $pushCmd = if ($UseRebase) { "git push origin master --force-with-lease" } else { "git push origin master" } - Write-ColorOutput "[DRY RUN] $pushCmd" "Gray" + Write-ColorOutput "Sync completed successfully!" "Green" + Write-ColorOutput "" + Write-ColorOutput "Next steps:" "Cyan" + Write-ColorOutput " Please manually push to your repository: git push origin master" "White" + if ($UseRebase) { + Write-ColorOutput " (If using rebase, you might need: git push origin master --force-with-lease)" "Yellow" } - Write-ColorOutput "Sync completed successfully!" "Green" } else { Write-ColorOutput "No new commits from upstream. Checking for local changes..." "Blue" @@ -103,17 +94,9 @@ function Sync-Repositories { Write-ColorOutput "Found local changes to push:" "Yellow" Write-ColorOutput $localCommits "Gray" - Write-ColorOutput "Pushing local changes..." "Green" - if (-not $DryRun) { - git push origin master - if ($LASTEXITCODE -ne 0) { - Write-ColorOutput "Push failed!" "Red" - return - } - } else { - Write-ColorOutput "[DRY RUN] git push origin master" "Gray" - } - Write-ColorOutput "Push completed!" "Green" + Write-ColorOutput "" + Write-ColorOutput "Next steps:" "Cyan" + Write-ColorOutput " Please manually push to your repository: git push origin master" "White" } else { Write-ColorOutput "Nothing to sync." "Blue" } @@ -133,6 +116,8 @@ function Show-Help { Write-ColorOutput " .\sync-repos.ps1 # Sync using merge" "White" Write-ColorOutput " .\sync-repos.ps1 -UseRebase # Sync using rebase" "White" Write-ColorOutput " .\sync-repos.ps1 -DryRun # Preview mode" "White" + Write-ColorOutput "" + Write-ColorOutput "Note: Script will NOT automatically push to your repository." "Yellow" } # Main program