The following instructions will help you make a step-by-step changes leading just to the desired result.
There are two ways to achieve the result.
With git rebase -i
This is faster but requires using a text editor.
git checkout master
git branch backup
#pick the sha1 of a commit before the one that will consume further commits.
git rebase -i 9d89b1b
This opens an editor with the text. Change it this way:
pick 6c7da1a Update README.md
squash 834b3b6 Update README.md
squash 4d2ed26 Update README.md
squash 585b586 Update README.md
squash be327e8 Update README.md
pick ba7e5ec PPath begins...
...
Now save and exit. If you're in vim, that's how to exit. A new editor opens with commit message. You can leave it intact or change to whatever you think is good.
# This is a combination of 3 commits.
# The first commit's message is:
Update README.md
...
Save and exit again. Job's done.
With git reset --soft.
This is longer but doesn't require side tools.
#start with a backup
git checkout master
git branch backup
#this returns head to be327e8 and brings the difference into index.
git reset --soft be327e8
# save that index for future use
git stash save
#same trick again
git reset --soft 9d89b1b
#recommit our changes
git commit -m'Update readme.md'
# now use the stashed changes
git stash apply
git commit -m'PPath begins...'
# check the result
git log --oneline
# now if everything is ABSOLUTELY FINE, you can delete the backup
git stash drop
A few links to explain what's going on:
Can you explain what "git reset" does in plain english?
Git cheatsheet