Rebase all theme-* branches onto main, resolving conflicts while preserving each theme's visual identity. Force-pushes directly to theme branches with backup tags. Run as a scheduled task or one-off.
You are running autonomously as a scheduled task. Do not ask questions or wait for input — make decisions and proceed. If something fails, handle it and move on to the next theme.
This repository (yournextstore/yournextstore) has a main branch (the default template) and multiple theme-* branches that are visual variants. Theme branches have their own colors, layouts, hero sections, typography, and copy — but share the same underlying logic, SDK, components, and infrastructure as main.
Your job: rebase every theme branch onto the latest main so themes pick up infrastructure improvements, bug fixes, SDK updates, and dependency bumps — while preserving each theme's visual identity completely.
git fetch origin
List all remote theme branches:
git branch -r | grep 'origin/theme-' | sed 's|origin/||' | xargs
Process every theme branch found. Track results as you go — you will need them for the summary at the end.
For each THEME_BRANCH (e.g., theme-cosmetics), do the following. If one theme fails, abort that theme's rebase, record the failure, and continue to the next theme. Never let one failure stop the entire run.
Set REBASE_BRANCH = ${THEME_BRANCH}-rebase.
git rev-list --count origin/${THEME_BRANCH}..origin/main
If the count is 0, the theme is already up to date. Log it and move to the next theme.
Create a backup tag so the old state can be recovered if anything goes wrong:
git tag backup/${THEME_BRANCH}/$(date +%Y-%m-%d) origin/${THEME_BRANCH}
git push origin backup/${THEME_BRANCH}/$(date +%Y-%m-%d)
Then create the working branch:
git checkout -B ${REBASE_BRANCH} origin/${THEME_BRANCH}
git rebase origin/main
If this succeeds cleanly (exit code 0), skip to step 2e.
When conflicts occur, resolve them iteratively. For each round:
git diff --name-only --diff-filter=UGIT_EDITOR=true git rebase --continue.For each conflicted file: read the file contents, resolve ALL conflict markers by editing the file to produce a clean result, then git add the file.
CRITICAL — during git rebase main, conflict marker sides are SWAPPED vs a normal merge:
<<<<<<< HEAD / "ours" = MAIN (logic updates, SDK changes, bug fixes, deps)>>>>>>> ... / "theirs" = THEME (visual design, JSX, components, classNames, styling)Resolve conflicted files in this order: package.json first (so bun.lock can regenerate), then bun.lock (just regenerate, never manually resolve), then everything else.
CSS files (*.css)
ALWAYS prefer the theme branch (theirs). Keep all theme colors, fonts, spacing, variables, and visual styling. Only add new CSS rules or variables from main (ours) that don't exist in the theme. Never replace or remove theme-specific styles.
React/JSX files (*.tsx, *.jsx)
START from the theme branch (theirs) code — copy it as-is. Then carefully port logic changes from main (ours) INTO the theme code: updated hooks, state, event handlers, data fetching, SDK/API calls, utility functions, types, and imports. Keep the theme's JSX structure, components, className attributes, Tailwind classes, styling, and layout UNCHANGED. The final file must LOOK like the theme but have main's updated logic. NEVER start from main's code and restyle it — always start from theme and add main's logic into it. If main introduces entirely new JSX elements, sections, or components that don't exist in the theme yet, you MUST restyle them to match the theme — use the theme's color palette, typography, Tailwind class conventions, spacing, and component patterns. Study 2-3 nearby theme components as a reference for the correct visual style.
package.json
Merge both: use main's (ours) dependency versions for shared packages, but keep any theme-only additions from the theme (theirs). Ensure valid JSON. After resolving, run bun install and git add bun.lock.
bun.lock
Never resolve manually. Run bun install to regenerate, then git add bun.lock.
next.config.ts / next.config.mjs / next.config.js
Keep the theme's (theirs) config as the base. Only add new config options from main (ours) that don't already exist in the theme. Preserve all theme-specific entries (remotePatterns, image domains, rewrites).
Tailwind config files ALWAYS prefer the theme branch (theirs). Keep all theme customizations, colors, fonts, extensions. Only add new utilities or plugins from main (ours) that don't conflict.
All other files Start from the theme branch (theirs) code. Port logic fixes, type fixes, SDK changes, and bug fixes from main (ours) into the theme code. Never replace theme content wholesale with main's version.
main in a themed store breaks the illusion. Check the theme's existing components for reference.main's default styling verbatim.<<<<<<<, =======, >>>>>>>) remain.git add the file.bun install
git add bun.lock
git commit -m "chore: regenerate bun.lock after rebase"
bunx biome check
If biome reports auto-fixable issues:
bunx biome check --write
git add -A
git commit -m "chore: fix lint issues after rebase"
If there are unfixable errors, attempt to fix them (max 2 attempts). If still broken, note them in the summary and continue — do not block on lint.
Force-push the rebased branch directly to the theme branch (backup tag was created in step 2b):
git push --force-with-lease origin ${REBASE_BRANCH}:${THEME_BRANCH}
If the rebase cannot be completed for this theme:
git rebase --abortgh issue create \
--title "Rebase failed: ${THEME_BRANCH}" \
--body "<explanation of what failed and why>" \
--label "rebase-failed"
After processing all themes, output a summary table:
| Theme | Status | Conflicts Resolved | Notes |
|---|---|---|---|
| theme-cosmetics | success | 3 files | — |
| theme-sneakers | up to date | — | — |
| theme-cbd | failed | — | bun install failed |
main branch. Only create/push *-rebase branches and force-push to theme branches.--force-with-lease (not --force) when pushing.bun install fails for a theme, that theme is a blocker — abort it and move on.git rebase --abort, git checkout main) before moving to the next theme so you don't carry dirty state forward.git checkout main to reset to a clean state.*-rebase branch after pushing to keep git state clean.