> For the complete documentation index, see [llms.txt](https://gittutorial.gitbook.io/practical-git-via-gitextensions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gittutorial.gitbook.io/practical-git-via-gitextensions/rewrite-history/how-to-squash-commits-in-middle.md).

# Squashing Commits in Middle

If the commits to be squahed are not the last few commits, an interactive rebase is needed. Similar to how we reword commits in middle, we start an interactive rebase, but this time instead of `reword`, we change the `pick` to `s` or `squash` for the second commit meaning squash the second up into the first commit.

```
pick d310b7c35 WIP: Fix blah blah
s f3ee84093 WIP: Continue Fix blah blah
pick 07ec28ec2 Fix another stupid bug
```

After saved and closed the Editor, Git then will popup the Editor asking for the new commit message of the squashed commits.

```
# This is a combination of 2 commits.
# This is the 1st commit message:

WIP: Fix blah blah

# This is the commit message #1:

WIP: Continue Fix blah blah

```

We now need to replace the `WIP: Fix blah blah` with a new commit message `Fix blahblah`and remove the `WIP: Continue Fix blah blah`.

Once finished it looks like below (I created a `before_rebase` branch so we can see it more clearly):<br>

![](https://1560106033-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LS9bmsupx6ftQfO0PH7%2F-LS9gPNmHWJl2fT-koJh%2F-LS9h4GVyr7HvFBIA-pe%2Fimage.png?alt=media\&token=133c2f94-ff9a-4035-911c-98cd190921ef)

The `fixup` option: `fixup` is very similar to `squash` except that `fixup` uses the commit message of the first commit whereas `squash` requires a new commit message.<br>
