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
docs: document --squashed-merge rebase flag in README and CHANGELOG
Add --squashed-merge flag documentation to rebase command options,
examples, recovery options, and quick reference sections. Update
CHANGELOG with squash-merge safety feature entries.
Copy file name to clipboardExpand all lines: README.md
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ When you run `git chain rebase`, git-chain intelligently updates each branch in
74
74
>
75
75
> When Git's fork-point detection fails, git-chain automatically falls back to using `git merge-base`, which finds the most recent common ancestor between two branches. While this ensures rebasing can proceed, it might be less precise than using the true fork-point.
76
76
77
-
4.**Handling Squash Merges**: If you've squash-merged a branch into its parent (combining all commits into one), git-chain detects this and prevents duplicate changes.
77
+
4.**Handling Squash Merges**: If you've squash-merged a branch into its parent (combining all commits into one), git-chain detects this and automatically creates a backup branch before resetting the branch to its parent. You can control this behavior with the `--squashed-merge` flag (see Command Options below).
78
78
79
79
5.**The Actual Rebasing**: For each branch, git-chain runs a command similar to:
80
80
```
@@ -100,6 +100,17 @@ 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
+
-**`--squashed-merge=<mode>`**: How to handle branches detected as squash-merged
104
+
```
105
+
git chain rebase --squashed-merge=reset # Default: auto-backup + reset to parent
106
+
git chain rebase --squashed-merge=skip # Skip the squash-merged branch
107
+
git chain rebase --squashed-merge=rebase # Force normal rebase despite detection
108
+
```
109
+
When git-chain detects that a branch has been squash-merged into its parent:
110
+
-**`reset`** (default): Creates a backup branch (`backup-<chain>/<branch>`) before resetting the branch to match its parent with `git reset --hard`. This is the safest option — your original commits are preserved in the backup branch.
111
+
-**`skip`**: Leaves the branch untouched and continues with the next branch in the chain.
112
+
-**`rebase`**: Ignores the squash-merge detection and performs a normal rebase. This may cause conflicts if the branch has multiple commits.
113
+
103
114
### Examples (`git chain rebase`)
104
115
105
116
Here are some common scenarios and how to handle them with git-chain rebase:
@@ -124,7 +135,17 @@ git chain rebase --ignore-root
124
135
```
125
136
This skips rebasing the first branch onto the root branch.
126
137
127
-
#### 3. Careful rebasing with potential conflicts
138
+
#### 3. Handling squash-merged branches
139
+
140
+
**Scenario**: A branch in your chain was squash-merged into its parent, and you want to skip it during rebase.
141
+
142
+
**Solution**:
143
+
```
144
+
git chain rebase --squashed-merge=skip
145
+
```
146
+
This skips any branches detected as squash-merged, leaving them untouched while rebasing the rest of the chain.
147
+
148
+
#### 4. Careful rebasing with potential conflicts
128
149
129
150
**Scenario**: You anticipate conflicts and want to handle each branch separately.
If a rebase goes wrong, Git Chain provides several recovery options:
192
213
193
-
1.**Backup Branches**: If you used `--backup`, you can restore using:
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:
194
215
```
195
216
git checkout branch-name
196
-
git reset --hard branch-name-backup
217
+
git reset --hard backup-chain-name/branch-name
197
218
```
198
219
199
220
2.**Reflog**: Even without backups, you can recover using Git's reflog:
@@ -587,6 +608,11 @@ git chain rebase --step
587
608
# Skip rebasing the first branch onto the root branch
588
609
git chain rebase --ignore-root
589
610
611
+
# Specify how to handle squash-merged branches during rebase
612
+
git chain rebase --squashed-merge=reset # Auto-backup + reset (default)
613
+
git chain rebase --squashed-merge=skip # Skip squash-merged branches
614
+
git chain rebase --squashed-merge=rebase # Force normal rebase
615
+
590
616
# Merge all branches in the current chain (preserves history)
0 commit comments