いくつか方法がありそう。[[Soft reset (Git)|Soft reset]]を使う方法。
## Soft resetを使う
`コミット2` から `コミット4` をまとめたい場合
```mermaid
gitGraph:
commit id: "初コミット"
commit id: "コミット2"
commit id: "コミット3"
commit id: "コミット4" type: HIGHLIGHT
```
```console
git reset --soft <初コミット>
git commit -m "Aggregated commit"
```
結果こうなる。
```mermaid
gitGraph:
commit id: "初コミット"
commit id: "Aggregated commit" type: HIGHLIGHT
```