---
description: Rebase the current branch, resolve any merge conflicts, and continue the git rebase
---

# Rebase with Conflict Resolution

Rebase the current branch and resolve any merge conflicts.

This command works both to **start a fresh rebase** and to **resume a rebase already in progress**. If a `git rebase` is underway with unresolved conflicts, skip straight to step 1 to assess the current state and resolve them.

## Steps

1. **Check status** - Run `git status` to understand the state of the rebase and identify conflicted files

2. **Separate auto-generated files from real content** - Check each conflicted file for the `<!-- AUTO-GENERATED FILE -->` header comment. These files are regenerated by tooling and don't need manual resolution.
   - **Auto-generated files** (e.g., `tripwires.md`, `index.md` with the auto-generated header): Accept either side (`git checkout --theirs <file>` or `git checkout --ours <file>`), stage with `git add`, and regenerate after the rebase completes (e.g., `erk docs sync` for tripwires/index files).
   - **Real content files**: Proceed to step 3 for manual resolution.

3. **For each real content file:**

For each conflicted file that is NOT auto-generated:

a. **Read the file** - Understand both sides of the conflict by examining the conflict markers:

- `<<<<<<< HEAD` marks the start of your local changes
- `=======` separates local from incoming changes
- `>>>>>>> <commit>` marks the end of incoming changes

b. **Understand intent** - Determine what each side was trying to accomplish:

- What was the local change trying to do?
- What was the remote change trying to do?
- Are they complementary or contradictory?

c. **Resolve intelligently:**

- If changes are complementary -> merge both
- If changes conflict semantically -> prefer the more recent/complete version
- If unclear -> ask the user for guidance

d. **Remove all conflict markers** - The resolved file should have no `<<<<<<<`, `=======`, or `>>>>>>>` markers

e. **Stage the resolution** - `git add <file>`

4. **After resolving all conflicts:**
   - If project memory includes a precommit check, run it and ensure no failures
   - Stage the resolved files with `git add`
   - Continue the rebase with `git rebase --continue`

5. **Loop** - If the rebase continues with more conflicts, repeat the process

6. **Regenerate auto-generated files** - If any auto-generated files were resolved in step 2, regenerate them now:
   - For tripwires/index files: `erk docs sync`
   - Commit the regenerated files separately

7. **Verify completion** - Check git status and recent commit history to confirm success

8. **Push changes** - After rebase, the branch will have diverged from origin. Push the rebased branch:
   - For Graphite users: `gt submit` (or `gt ss`)
   - For git-only users: `git push --force-with-lease`
