Today I did some work on a branch in git only to discover that I based it on some unstable code rather than the stable code that I usually want to use as a baseline.

You can fix this by using a bit of git’s rebase magic:

$ git rebase --onto master testing

This moves the entire current branch onto another.