Change git history

Here’s the way to change your git history (I found it here):

git rebase -i HEAD~3

Then you should see this in a text editor:

pick dd56df4 added support for rocket launchers
pick 36c7dba made it power up the hand thrusters when fingers are splayed
pick 7482e0d added heat seeking targeting system

Change the word pick to edit of the commit that you want to edit and save/exit the editor and you will see this:

Stopped at 7482e0d... added heat seeking targeting system

7482e0d is now the last commit so you can now amend stuff to it. If you want to add a file to the commit add it in now:

git add targeting/friendly_detection.c

All done? Amend the commit:

git commit --amend

Then you are given a chance to edit the commit message, but you can just exit the editor if you want to keep it the same.

Now you just need to rebase it:

git rebase --continue

And you’re done!