Use git rebase -i head~5 instead of git rebase -i head~4
What rebase is used for?
It's used to apply commits on top of history but, in some case (such this) is used also to rewrite the history
What is -i flag?
It is used to start an interactive process where an editor (such vi) will be showed to you and where you can choose from different options
Why head~5
Because you need to rewrite history for last five commits
What should I do next?
With interactive rebasing, something like this will be showed to you
pick 9e40be3 First commit message
pick 6e20a2a Second commit message
pick 0b06199 Third commit message
pick 3b4d266 Fourth commit message
pick c273e2f Fifth commit message
and below
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
where c273e2f (for instance) is the hash that identify a commit.
Now you can choose what to do with your commits. If you need first four commits to be only one, you can apply either a fixup or a squash (see commands above).
With fixup you won't be able to "travel" commits messages and only first commit message (or to be honest the commit message for commit you're fixing up) will be taken.
With squash you can choose what message to keep and even edit them (another "editor page" will be showed to you if this is chosen methodology).
A working example for you could be something like
pick 9e40be3 First commit message
f 6e20a2a Second commit message
f 0b06199 Third commit message
f 3b4d266 Fourth commit message
pick c273e2f Fifth commit message
This will result in two commits (first with second-third-fourth "merged" and fifth) where first commit will have first original commit message whether fifth commit will have fifth original commit message
Pay attention
As you are going to rewrite history, when you push, you need to specify -f as flag and if you're doing this in a "public" branch (such dev, or master, or whatever) this could be a pain in the back for who needs to push to that branch aswell.
head~<n>where<n>is number of commits behind this