Watch how to edit commits in Git

At the beginning of this video, I have some uncommitted changes. They include some new features and some fixes for previous commits.

I have a fix for the turnover_declarations_helper.rb and I decided to rewrite initTurnoverUnitAndPeriodSelects in turnover_declaration.js to be a function.

First, I run git add -p app/helpers/turnover_declarations_helper.rb to pick the bits for fixing previous commits and commit it.

Then, I run git add -p public/javascripts/controllers/turnover_declarations.js to pick the bits for fixing previous commits and commit it. (You can commit them in one commit as well, since they both fixes the same commit)

After that, I run git rebase -i qa to reorder the commits, then mark my fix commits as fixups.

In case you rebase and then realize it is not what you want, have a look at "git reflog", it has the commit from before you start the rebase. You can look at the commits using git log db7f236 and do git reset --hard db7f236 to get back to the point before you rebase.