Skip to content

Commit a720586

Browse files
committed
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.
1 parent da964be commit a720586

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Updated CLAUDE.md to reference Makefile targets instead of raw cargo commands
1616

1717
### Added
18+
- Added `--squashed-merge` flag to `rebase` command with three modes:
19+
- `reset` (default): auto-creates a backup branch before destructive `git reset --hard`
20+
- `skip`: skips squash-merged branches entirely during rebase
21+
- `rebase`: forces normal rebase despite squash-merge detection
22+
- Added `SquashedRebaseHandling` enum in `types.rs` for rebase-specific squash handling
23+
- Added integration tests for squash-merge handling in rebase:
24+
- `rebase_squashed_merge_skip`, `rebase_squashed_merge_force_rebase`
1825
- Added `lint` Makefile target (combines `fmt-check` + `clippy-strict`)
1926
- Added `test-file` Makefile target for running all tests in a specific file
2027
- Added integration tests for error propagation:
2128
- `rebase_nonexistent_chain`, `rebase_dirty_working_directory`, `rebase_missing_branch_in_chain`
2229
- `backup_nonexistent_chain`, `push_nonexistent_chain`, `prune_nonexistent_chain`
2330

2431
### Fixed
32+
- Squash-merge reset in `rebase` now auto-creates a backup branch before destructive `git reset --hard`
2533
- Updated `.PHONY` declaration in Makefile to include all targets
2634

2735
### Removed

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ When you run `git chain rebase`, git-chain intelligently updates each branch in
7474
>
7575
> 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.
7676
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).
7878

7979
5. **The Actual Rebasing**: For each branch, git-chain runs a command similar to:
8080
```
@@ -100,6 +100,17 @@ 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+
- **`--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+
103114
### Examples (`git chain rebase`)
104115

105116
Here are some common scenarios and how to handle them with git-chain rebase:
@@ -124,7 +135,17 @@ git chain rebase --ignore-root
124135
```
125136
This skips rebasing the first branch onto the root branch.
126137

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
128149

129150
**Scenario**: You anticipate conflicts and want to handle each branch separately.
130151

@@ -190,10 +211,10 @@ Rebasing branch feature/profiles onto feature/auth...
190211

191212
If a rebase goes wrong, Git Chain provides several recovery options:
192213

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:
194215
```
195216
git checkout branch-name
196-
git reset --hard branch-name-backup
217+
git reset --hard backup-chain-name/branch-name
197218
```
198219

199220
2. **Reflog**: Even without backups, you can recover using Git's reflog:
@@ -587,6 +608,11 @@ git chain rebase --step
587608
# Skip rebasing the first branch onto the root branch
588609
git chain rebase --ignore-root
589610
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+
590616
# Merge all branches in the current chain (preserves history)
591617
git chain merge
592618

0 commit comments

Comments
 (0)