Skip to content

Commit 8ae9840

Browse files
committed
docs: document rebase --continue and --abort in README and CHANGELOG
1 parent ab7b5a2 commit 8ae9840

2 files changed

Lines changed: 81 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Changed
11+
- Rebase conflict error message now shows numbered recovery steps with `--continue` and `--abort` instructions
1112
- Replaced `process::exit(1)` with proper error propagation in core operations
1213
- `rebase`, `backup`, `push`, `prune`, and `pr` operations now return `Result<(), Error>` instead of calling `process::exit(1)`
1314
- Errors propagate to the top-level handler in `main.rs` for consistent formatting
1415
- `check_gh_cli_installed()` returns `Result` instead of exiting directly
1516
- Updated CLAUDE.md to reference Makefile targets instead of raw cargo commands
1617

1718
### Added
19+
- Added `--continue` flag to `rebase` command for resuming a chain rebase after resolving conflicts
20+
- Loads saved state from `.git/chain-rebase-state.json`
21+
- Marks the conflicted branch as completed and resumes from the next pending branch
22+
- Uses pre-computed merge bases for correct rebasing after partial chain rebase
23+
- Added `--abort` flag to `rebase` command for rolling back a chain rebase
24+
- Aborts any in-progress git rebase
25+
- Restores all branches to their original positions using saved refs
26+
- Returns to the original branch and cleans up state file
27+
- Added chain rebase state tracking via `.git/chain-rebase-state.json`
28+
- Persists original branch refs, merge bases, and per-branch rebase status
29+
- Enables recovery from conflicts without re-computing merge bases
30+
- Blocks new rebase when prior state exists (directs user to --continue or --abort)
31+
- Skipped for `--step` mode which re-runs from scratch each time
32+
- Added `ChainRebaseState`, `BranchState`, and `BranchRebaseStatus` types for state serialization
33+
- Added `rebase_state` module for state file I/O (read, write, check, delete)
34+
- Added `get_branch_commit_oid()` helper for capturing branch refs before rebase
35+
- Added integration tests for rebase state tracking:
36+
- `rebase_continue_with_remaining_branches`, `rebase_abort_after_conflict`
37+
- `rebase_continue_no_state`, `rebase_abort_no_state`, `rebase_blocked_when_state_exists`
38+
- Added `serde` dependency for JSON serialization of rebase state
1839
- Added `--squashed-merge` flag to `rebase` command with three modes:
1940
- `reset` (default): auto-creates a backup branch before destructive `git reset --hard`
2041
- `skip`: skips squash-merged branches entirely during rebase

README.md

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ Git Chain's rebase command offers customization through its flags:
100100
```
101101
Useful when you want to update relationships between chain branches without incorporating root branch changes.
102102

103+
- **`--continue`**: Resume a chain rebase after resolving conflicts
104+
```
105+
git chain rebase --continue
106+
```
107+
After resolving a rebase conflict and completing the git-level rebase (`git rebase --continue`), use this to continue rebasing the remaining branches in the chain. Uses saved merge bases from the original run.
108+
109+
- **`--abort`**: Abort a chain rebase and restore all branches
110+
```
111+
git chain rebase --abort
112+
```
113+
Rolls back the entire chain rebase by restoring all branches to their original positions before the rebase started. Aborts any in-progress git rebase and cleans up the state file.
114+
103115
- **`--squashed-merge=<mode>`**: How to handle branches detected as squash-merged
104116
```
105117
git chain rebase --squashed-merge=reset # Default: auto-backup + reset to parent
@@ -145,7 +157,26 @@ git chain rebase --squashed-merge=skip
145157
```
146158
This skips any branches detected as squash-merged, leaving them untouched while rebasing the rest of the chain.
147159

148-
#### 4. Careful rebasing with potential conflicts
160+
#### 4. Recovering from rebase conflicts
161+
162+
**Scenario**: A rebase conflict occurred and you need to resolve it and continue.
163+
164+
**Solution**:
165+
```
166+
# After resolving the conflict in the git-level rebase:
167+
git add <resolved-files>
168+
git rebase --continue
169+
170+
# Then resume the chain rebase for remaining branches:
171+
git chain rebase --continue
172+
```
173+
174+
Or if you want to abort the entire chain rebase and restore all branches:
175+
```
176+
git chain rebase --abort
177+
```
178+
179+
#### 5. Careful rebasing with potential conflicts
149180

150181
**Scenario**: You anticipate conflicts and want to handle each branch separately.
151182

@@ -157,37 +188,34 @@ This rebases one branch at a time, waiting for your confirmation between steps.
157188

158189
### Handling Rebase Conflicts
159190

160-
When rebasing branches in a chain, conflicts can sometimes occur. Git Chain handles conflicts as follows:
191+
When rebasing branches in a chain, conflicts can sometimes occur. Git Chain saves the chain rebase state to `.git/chain-rebase-state.json`, enabling proper recovery via `--continue` and `--abort`.
161192

162193
1. **Conflict Detection**: When a rebase conflict occurs, git-chain:
163194
- Pauses the rebasing process at the conflicted commit
195+
- Saves the chain rebase state (original branch refs, merge bases, per-branch status)
164196
- Leaves the repository in a conflicted state for you to resolve
165-
- Provides information about which branch is being rebased and where the conflict occurred
166-
- May create automatic backup branches if conflicts are detected
197+
- Provides numbered recovery steps with `--continue` and `--abort` instructions
167198

168199
2. **Resolution Process**:
169200
- The conflicted files will be marked with conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)
170201
- Resolve conflicts manually by editing the conflicted files
171202
- Add the resolved files with `git add <file>`
172-
- Continue the rebase with `git rebase --continue`
203+
- Continue the git-level rebase with `git rebase --continue`
173204

174205
3. **Continuing After Resolution**:
175-
- After resolving the conflicts and continuing the rebase for the current branch, you can resume updating the chain:
206+
- After resolving the conflicts and completing the git-level rebase, resume the chain rebase:
176207
```
177-
git chain rebase
208+
git chain rebase --continue
178209
```
179-
- Git Chain will pick up where it left off, continuing with the remaining branches
210+
- Git Chain loads the saved state and continues rebasing the remaining branches using pre-computed merge bases
211+
- After all branches are rebased, the state file is cleaned up and you are returned to your original branch
180212

181213
4. **Aborting a Problematic Rebase**:
182-
- If you decide not to resolve the conflicts, you can abort the current rebase:
214+
- If you decide not to resolve the conflicts, abort the entire chain rebase:
183215
```
184-
git rebase --abort
185-
```
186-
- Then, if you created backup branches, you can restore from them:
187-
```
188-
git checkout branch-name
189-
git reset --hard branch-name-backup
216+
git chain rebase --abort
190217
```
218+
- This restores all branches to their original positions, aborts any in-progress git rebase, and cleans up the state file
191219

192220
**Example Conflict Workflow**:
193221
```
@@ -201,8 +229,10 @@ error: could not apply 1a2b3c4... Add authentication feature
201229
$ vim src/auth.js
202230
$ git add src/auth.js
203231
$ git rebase --continue
204-
Successfully rebased branch feature/auth
205232
233+
# Resume the chain rebase for remaining branches
234+
$ git chain rebase --continue
235+
Continuing chain rebase...
206236
Rebasing branch feature/profiles onto feature/auth...
207237
# Continues with remaining branches
208238
```
@@ -211,20 +241,25 @@ Rebasing branch feature/profiles onto feature/auth...
211241

212242
If a rebase goes wrong, Git Chain provides several recovery options:
213243

214-
1. **Backup Branches**: Backup branches are automatically created when squash-merged branches are reset (via `--squashed-merge=reset`). You can also create backups manually with `git chain backup`. To restore:
244+
1. **Abort Chain Rebase**: If a chain rebase is in progress (state file exists), abort and restore all branches:
245+
```
246+
git chain rebase --abort
247+
```
248+
249+
2. **Backup Branches**: Backup branches are automatically created when squash-merged branches are reset (via `--squashed-merge=reset`). You can also create backups manually with `git chain backup`. To restore:
215250
```
216251
git checkout branch-name
217252
git reset --hard backup-chain-name/branch-name
218253
```
219254

220-
2. **Reflog**: Even without backups, you can recover using Git's reflog:
255+
3. **Reflog**: Even without backups, you can recover using Git's reflog:
221256
```
222257
git checkout branch-name
223258
git reflog
224259
git reset --hard branch-name@{1} # Reset to previous state
225260
```
226261

227-
3. **Abort In-Progress Rebase**: If a rebase is still in progress:
262+
4. **Abort Git-Level Rebase**: If only the git-level rebase needs aborting (before using `--abort`):
228263
```
229264
git rebase --abort
230265
```
@@ -602,6 +637,12 @@ git chain list
602637
# Rebase all branches in the current chain (rewrites history)
603638
git chain rebase
604639
640+
# Continue chain rebase after resolving conflicts
641+
git chain rebase --continue
642+
643+
# Abort chain rebase and restore all branches
644+
git chain rebase --abort
645+
605646
# Rebase one branch at a time
606647
git chain rebase --step
607648

0 commit comments

Comments
 (0)