You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-19Lines changed: 60 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,18 @@ Git Chain's rebase command offers customization through its flags:
100
100
```
101
101
Useful when you want to update relationships between chain branches without incorporating root branch changes.
102
102
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
+
103
115
-**`--squashed-merge=<mode>`**: How to handle branches detected as squash-merged
104
116
```
105
117
git chain rebase --squashed-merge=reset # Default: auto-backup + reset to parent
@@ -145,7 +157,26 @@ git chain rebase --squashed-merge=skip
145
157
```
146
158
This skips any branches detected as squash-merged, leaving them untouched while rebasing the rest of the chain.
147
159
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
149
180
150
181
**Scenario**: You anticipate conflicts and want to handle each branch separately.
151
182
@@ -157,37 +188,34 @@ This rebases one branch at a time, waiting for your confirmation between steps.
157
188
158
189
### Handling Rebase Conflicts
159
190
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`.
161
192
162
193
1.**Conflict Detection**: When a rebase conflict occurs, git-chain:
163
194
- Pauses the rebasing process at the conflicted commit
195
+
- Saves the chain rebase state (original branch refs, merge bases, per-branch status)
164
196
- 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
167
198
168
199
2.**Resolution Process**:
169
200
- The conflicted files will be marked with conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)
170
201
- Resolve conflicts manually by editing the conflicted files
171
202
- 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`
173
204
174
205
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:
176
207
```
177
-
git chain rebase
208
+
git chain rebase --continue
178
209
```
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
180
212
181
213
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:
183
215
```
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
190
217
```
218
+
- This restores all branches to their original positions, aborts any in-progress git rebase, and cleans up the state file
191
219
192
220
**Example Conflict Workflow**:
193
221
```
@@ -201,8 +229,10 @@ error: could not apply 1a2b3c4... Add authentication feature
If a rebase goes wrong, Git Chain provides several recovery options:
213
243
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:
215
250
```
216
251
git checkout branch-name
217
252
git reset --hard backup-chain-name/branch-name
218
253
```
219
254
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:
221
256
```
222
257
git checkout branch-name
223
258
git reflog
224
259
git reset --hard branch-name@{1} # Reset to previous state
225
260
```
226
261
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`):
228
263
```
229
264
git rebase --abort
230
265
```
@@ -602,6 +637,12 @@ git chain list
602
637
# Rebase all branches in the current chain (rewrites history)
0 commit comments