|
| 1 | +--- |
| 2 | +description: Sync downstream repo with upstream main, preserving downstream-specific files |
| 3 | +--- |
| 4 | + |
| 5 | +Sync downstream repository with upstream changes while preserving downstream-specific files. |
| 6 | + |
| 7 | +# Important Instructions |
| 8 | + |
| 9 | +- **ALWAYS** start from a detached HEAD: `git checkout --detach` |
| 10 | +- **DO NOT** use TodoWrite tool |
| 11 | +- **DO NOT** ask for confirmations - just execute |
| 12 | +- **BE CONCISE** - minimal output, only show final summary |
| 13 | + |
| 14 | +# Execution Steps |
| 15 | + |
| 16 | +Execute these commands in sequence: |
| 17 | + |
| 18 | +```bash |
| 19 | +# 1. Start from detached HEAD (REQUIRED) |
| 20 | +git checkout --detach |
| 21 | + |
| 22 | +# 2. Delete old sync branch if it exists |
| 23 | +git branch -D sync-downstream 2>/dev/null || true |
| 24 | + |
| 25 | +# 3. Fetch and create sync branch |
| 26 | +git fetch downstream |
| 27 | +git fetch upstream |
| 28 | +git checkout -b sync-downstream upstream/main |
| 29 | +git merge -s ours --no-commit downstream/main |
| 30 | + |
| 31 | +# 4. Restore downstream files (read from .downstream-preserve or use defaults) |
| 32 | +git checkout downstream/main -- .ci-operator.yaml .snyk .tekton/ Dockerfile.ci Dockerfile.ocp Makefile-ocp.mk OWNERS mcp_config.toml renovate.json |
| 33 | + |
| 34 | +# 5. Update dependencies |
| 35 | +go mod tidy |
| 36 | +go mod vendor |
| 37 | +git add vendor/ |
| 38 | + |
| 39 | +# 6. Commit everything in ONE commit |
| 40 | +git commit -am "sync: merge upstream main with downstream config" |
| 41 | +``` |
| 42 | + |
| 43 | +# Output |
| 44 | + |
| 45 | +After completion, show ONLY: |
| 46 | +- Commit hash |
| 47 | +- File change summary: `git diff --stat downstream/main..HEAD | tail -1` |
| 48 | +- Next steps: |
| 49 | + ``` |
| 50 | + git push origin sync-downstream |
| 51 | + gh pr create --base downstream/main |
| 52 | + ``` |
| 53 | + |
| 54 | +# Error Handling |
| 55 | + |
| 56 | +If any command fails, stop immediately and show the error. No rollback needed - user can investigate. |
0 commit comments