| name | rebase-main |
| description | Safely update local main from origin/main, rebase the current flutter_calendar_carousel work branch, resolve conflicts without losing staged, unstaged, untracked, ignored, or generated work, and restore the original working-tree state. Use when asked to pull main, rebase onto main, update a branch, or fix a stuck rebase. |
Rebase Main
Update main, rebase the current work branch, and preserve all local work. Do
not commit or push unless separately authorized.
Establish And Safeguard
- Read
AGENTS.md.
- Record branch, HEAD, upstream, worktrees, in-progress Git operations, staged,
unstaged, untracked, and relevant ignored files with content fingerprints.
- Stop if detached, currently on
main, another operation is active, or main
is checked out elsewhere and cannot be updated safely.
- Default to
origin/main; derive another target only from repository evidence.
- If dirty, create one named stash with
--include-untracked, never --all.
Confirm the tracked and untracked worktree is clean. Preserve ignored secrets
and environment files in place.
The stash is a recovery point. Do not drop it until restoration is exact.
Update And Rebase
- Fetch
origin main.
- Before switching, verify no recorded ignored/local path collides with a path
tracked by the destination. Use
git checkout --no-overwrite-ignore for
guarded transitions.
- Check out
main and run git merge --ff-only origin/main. Stop on divergence;
never reset or create a merge commit to conceal it.
- Confirm local
main and origin/main are identical.
- Check out the recorded work branch with the same collision guard.
- Run
git rebase origin/main.
- Resolve each conflict by inspecting base, new-main, and work-branch intent.
Preserve compatible changes and regenerate derived files through their tools.
Never apply blanket ours/theirs resolution.
Never use git reset --hard, git checkout --, git clean, or destructive
recovery shortcuts.
Restore And Verify
- Apply the named stash with its index.
- Resolve restoration conflicts carefully. Keep the stash while any mismatch
remains.
- Compare staged, unstaged, untracked, and ignored fingerprints to the initial
snapshot.
- Drop only the named stash after exact restoration.
- Run
git status, git diff --check, and affected lightweight checks.
- Report old/new main and branch heads plus restored working-tree state.
If the work branch was published, explain that rewritten history needs a later
git push --force-with-lease; do not perform it without explicit authorization.