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.4metadata:5 source: https://skillmd.com/skills/hyochan/rebase-main-56---78# Rebase main910Update `main`, rebase the current branch, and preserve every pre-existing11working-tree change. Do not commit or push unless separately authorized.1213## Establish the target14151. Record the current branch, `HEAD`, upstream, staged and unstaged changes,16 untracked files, and the ignored env files this repo depends on17 (`.env.local` carries the Convex dev URL) with content fingerprints.182. Stop if the checkout is detached, the current branch is `main`, another19 merge, rebase, or cherry-pick is active, or `main` is checked out in another20 worktree.213. Use `origin` and `main`.2223## Safeguard local work2425If the worktree is dirty:26271. Capture status and content fingerprints so restoration can be verified.282. Create one clearly named stash with `--include-untracked`. Never use `--all`:29 `.env.local`, credentials, and build caches must stay in place.303. Record the stash object and confirm the tracked and untracked worktree is31 clean.324. If a changed ignore rule makes a previously ignored file appear untracked, do33 not stash, move, or delete it. Add its exact path to `.git/info/exclude` as a34 recorded temporary safeguard, and only after confirming neither `main` nor35 the work branch tracks that path.365. If stashing fails or changes remain unexplained, stop before switching37 branches.3839Treat the stash as a recovery point. Do not drop it until restoration is40verified.4142## Update main and rebase4344Before every branch switch, compare each recorded ignored path against the45destination tree and stop on a tracked-path collision. Use46`git checkout --no-overwrite-ignore <branch>` for these transitions.47481. `git fetch origin main`, then check the recorded ignored paths against both49 the current `main` tree and the fetched `origin/main`.502. Check out `main` with `--no-overwrite-ignore`.513. `git merge --ff-only origin/main`. Never reset, force-update, or create a52 merge commit for a divergent local `main`.534. Confirm `main` and `origin/main` are the same commit. If local `main` is54 ahead, stop and report that divergence instead of rebasing onto unpublished55 work.565. Check out the work branch with `--no-overwrite-ignore` after repeating the57 collision check.586. `git rebase origin/main`.597. For each conflict, inspect the base, the main side, and the branch side.60 Preserve both compatible intents; never apply blanket `ours` or `theirs`.618. Run `git rebase --continue` only after reviewing the resolved files and the62 staged diff. If intent is ambiguous, stop with the conflict list and keep the63 rebase recoverable.6465Never use `git reset --hard`, `git checkout --`, or `git clean`.6667## Restore and verify68691. Apply the stash with its index so staged state returns.702. Resolve restoration conflicts with the same care. Do not drop the stash while71 any mismatch remains.723. Remove temporary `.git/info/exclude` entries once the restored ignore rules73 cover those paths again.744. Compare the restored staged, unstaged, and untracked state against the75 initial snapshot. Confirm `.env.local` still exists and was not added to Git.765. Drop only the named safeguard stash.776. Run `git status`, `git diff --check`, and `bun run typecheck`. Confirm the78 branch is based on the updated `main` and report the old and new heads.7980If the branch was already pushed, explain that the rewritten history needs a81later `git push --force-with-lease`. Never run that push unless authorized.