Rebase main
Update main, rebase the current branch, and preserve every pre-existing
working-tree change. Do not commit or push unless separately authorized.
Establish the target
- Record the current branch,
HEAD, upstream, staged and unstaged changes,
untracked files, and the ignored env files this repo depends on
(.env.local carries the Convex dev URL) with content fingerprints.
- Stop if the checkout is detached, the current branch is
main, another
merge, rebase, or cherry-pick is active, or main is checked out in another
worktree.
- Use
origin and main.
Safeguard local work
If the worktree is dirty:
- Capture status and content fingerprints so restoration can be verified.
- Create one clearly named stash with
--include-untracked. Never use --all:
.env.local, credentials, and build caches must stay in place.
- Record the stash object and confirm the tracked and untracked worktree is
clean.
- If a changed ignore rule makes a previously ignored file appear untracked, do
not stash, move, or delete it. Add its exact path to
.git/info/exclude as a
recorded temporary safeguard, and only after confirming neither main nor
the work branch tracks that path.
- If stashing fails or changes remain unexplained, stop before switching
branches.
Treat the stash as a recovery point. Do not drop it until restoration is
verified.
Update main and rebase
Before every branch switch, compare each recorded ignored path against the
destination tree and stop on a tracked-path collision. Use
git checkout --no-overwrite-ignore <branch> for these transitions.
git fetch origin main, then check the recorded ignored paths against both
the current main tree and the fetched origin/main.
- Check out
main with --no-overwrite-ignore.
git merge --ff-only origin/main. Never reset, force-update, or create a
merge commit for a divergent local main.
- Confirm
main and origin/main are the same commit. If local main is
ahead, stop and report that divergence instead of rebasing onto unpublished
work.
- Check out the work branch with
--no-overwrite-ignore after repeating the
collision check.
git rebase origin/main.
- For each conflict, inspect the base, the main side, and the branch side.
Preserve both compatible intents; never apply blanket
ours or theirs.
- Run
git rebase --continue only after reviewing the resolved files and the
staged diff. If intent is ambiguous, stop with the conflict list and keep the
rebase recoverable.
Never use git reset --hard, git checkout --, or git clean.
Restore and verify
- Apply the stash with its index so staged state returns.
- Resolve restoration conflicts with the same care. Do not drop the stash while
any mismatch remains.
- Remove temporary
.git/info/exclude entries once the restored ignore rules
cover those paths again.
- Compare the restored staged, unstaged, and untracked state against the
initial snapshot. Confirm
.env.local still exists and was not added to Git.
- Drop only the named safeguard stash.
- Run
git status, git diff --check, and bun run typecheck. Confirm the
branch is based on the updated main and report the old and new heads.
If the branch was already pushed, explain that the rewritten history needs a
later git push --force-with-lease. Never run that push unless authorized.
1---2name: rebase-main-53description: Safely update local main with a fast-forward-only pull, rebase the current branch onto it, resolve conflicts without losing local work, and restore staged, unstaged, and untracked changes. Use when the user asks to pull main and rebase, update a branch from main, fix rebase conflicts, or says rebase-main.4---56# Rebase main78Update `main`, rebase the current branch, and preserve every pre-existing9working-tree change. Do not commit or push unless separately authorized.1011## Establish the target12131. Record the current branch, `HEAD`, upstream, staged and unstaged changes,14 untracked files, and the ignored env files this repo depends on15 (`.env.local` carries the Convex dev URL) with content fingerprints.162. Stop if the checkout is detached, the current branch is `main`, another17 merge, rebase, or cherry-pick is active, or `main` is checked out in another18 worktree.193. Use `origin` and `main`.2021## Safeguard local work2223If the worktree is dirty:24251. Capture status and content fingerprints so restoration can be verified.262. Create one clearly named stash with `--include-untracked`. Never use `--all`:27 `.env.local`, credentials, and build caches must stay in place.283. Record the stash object and confirm the tracked and untracked worktree is29 clean.304. If a changed ignore rule makes a previously ignored file appear untracked, do31 not stash, move, or delete it. Add its exact path to `.git/info/exclude` as a32 recorded temporary safeguard, and only after confirming neither `main` nor33 the work branch tracks that path.345. If stashing fails or changes remain unexplained, stop before switching35 branches.3637Treat the stash as a recovery point. Do not drop it until restoration is38verified.3940## Update main and rebase4142Before every branch switch, compare each recorded ignored path against the43destination tree and stop on a tracked-path collision. Use44`git checkout --no-overwrite-ignore <branch>` for these transitions.45461. `git fetch origin main`, then check the recorded ignored paths against both47 the current `main` tree and the fetched `origin/main`.482. Check out `main` with `--no-overwrite-ignore`.493. `git merge --ff-only origin/main`. Never reset, force-update, or create a50 merge commit for a divergent local `main`.514. Confirm `main` and `origin/main` are the same commit. If local `main` is52 ahead, stop and report that divergence instead of rebasing onto unpublished53 work.545. Check out the work branch with `--no-overwrite-ignore` after repeating the55 collision check.566. `git rebase origin/main`.577. For each conflict, inspect the base, the main side, and the branch side.58 Preserve both compatible intents; never apply blanket `ours` or `theirs`.598. Run `git rebase --continue` only after reviewing the resolved files and the60 staged diff. If intent is ambiguous, stop with the conflict list and keep the61 rebase recoverable.6263Never use `git reset --hard`, `git checkout --`, or `git clean`.6465## Restore and verify66671. Apply the stash with its index so staged state returns.682. Resolve restoration conflicts with the same care. Do not drop the stash while69 any mismatch remains.703. Remove temporary `.git/info/exclude` entries once the restored ignore rules71 cover those paths again.724. Compare the restored staged, unstaged, and untracked state against the73 initial snapshot. Confirm `.env.local` still exists and was not added to Git.745. Drop only the named safeguard stash.756. Run `git status`, `git diff --check`, and `bun run typecheck`. Confirm the76 branch is based on the updated `main` and report the old and new heads.7778If the branch was already pushed, explain that the rewritten history needs a79later `git push --force-with-lease`. Never run that push unless authorized.