Rebase Main
Update main, rebase the work branch, and preserve all pre-existing work. Do
not commit, push, or force-push unless the user separately authorizes it.
Establish State
- Read
AGENTS.md and record the current branch, HEAD, upstream, worktrees,
staged changes, unstaged changes, untracked files, and relevant ignored local
files.
- Inspect
.git state for an active rebase, merge, cherry-pick, revert, or
bisect. Do not start a second operation.
- Stop if detached, already on
main for a rebase request, or the target base
cannot be identified safely.
- Use
origin/main only after confirming both refs exist.
Safeguard Work
If tracked or untracked changes exist, create one clearly named stash with
--include-untracked; never use --all. Record the stash object and verify the
worktree is clean. Fingerprint important ignored files and check that neither
destination tree tracks their exact paths before switching.
If a stale .git/index.lock or .git/HEAD.lock blocks progress, confirm its
age and verify no Git process owns it before removing only that exact lock. If
an earlier operation is active, inspect its head, target, todo, and conflicts;
continue or abort only when that preserves the recorded intent.
Update And Rebase
- Run
git fetch --prune origin.
- Check out
main without overwriting ignored files.
- Run
git merge --ff-only origin/main. Stop on local/remote divergence; do
not reset or create a merge commit.
- Confirm
main and origin/main resolve to the same commit.
- Check out the recorded work branch with the same ignored-path guard.
- Run
git rebase origin/main.
- For each conflict, inspect base, main, and work-branch intent. Regenerate
nitrogen/generated/** through yarn nitrogen or yarn prepare; never pick
a blanket side for generated output.
Never use git reset --hard, git checkout --, or git clean as recovery.
Restore And Verify
Apply the safeguard stash with its index. Resolve restoration conflicts, then
compare staged, unstaged, untracked, and ignored state with the initial
snapshot. Drop only the named stash after restoration is exact.
Run git status, git diff --check, and the lightweight checks affected by
conflict resolution. Report old and new main/work heads. If a published branch
was rewritten, explain that a later git push --force-with-lease is required
but do not perform it without authorization.
1---2name: rebase-main3description: Safely update local main from origin/main, rebase the current react-native-nitro-sound 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, or fix a stuck rebase.4---56# Rebase Main78Update `main`, rebase the work branch, and preserve all pre-existing work. Do9not commit, push, or force-push unless the user separately authorizes it.1011## Establish State12131. Read `AGENTS.md` and record the current branch, `HEAD`, upstream, worktrees,14 staged changes, unstaged changes, untracked files, and relevant ignored local15 files.162. Inspect `.git` state for an active rebase, merge, cherry-pick, revert, or17 bisect. Do not start a second operation.183. Stop if detached, already on `main` for a rebase request, or the target base19 cannot be identified safely.204. Use `origin/main` only after confirming both refs exist.2122## Safeguard Work2324If tracked or untracked changes exist, create one clearly named stash with25`--include-untracked`; never use `--all`. Record the stash object and verify the26worktree is clean. Fingerprint important ignored files and check that neither27destination tree tracks their exact paths before switching.2829If a stale `.git/index.lock` or `.git/HEAD.lock` blocks progress, confirm its30age and verify no Git process owns it before removing only that exact lock. If31an earlier operation is active, inspect its head, target, todo, and conflicts;32continue or abort only when that preserves the recorded intent.3334## Update And Rebase35361. Run `git fetch --prune origin`.372. Check out `main` without overwriting ignored files.383. Run `git merge --ff-only origin/main`. Stop on local/remote divergence; do39 not reset or create a merge commit.404. Confirm `main` and `origin/main` resolve to the same commit.415. Check out the recorded work branch with the same ignored-path guard.426. Run `git rebase origin/main`.437. For each conflict, inspect base, main, and work-branch intent. Regenerate44 `nitrogen/generated/**` through `yarn nitrogen` or `yarn prepare`; never pick45 a blanket side for generated output.4647Never use `git reset --hard`, `git checkout --`, or `git clean` as recovery.4849## Restore And Verify5051Apply the safeguard stash with its index. Resolve restoration conflicts, then52compare staged, unstaged, untracked, and ignored state with the initial53snapshot. Drop only the named stash after restoration is exact.5455Run `git status`, `git diff --check`, and the lightweight checks affected by56conflict resolution. Report old and new main/work heads. If a published branch57was rewritten, explain that a later `git push --force-with-lease` is required58but do not perform it without authorization.