title: How can I easily fixup a past commit?
body: <p>I just read <a href="https://stackoverflow.com/questions/493450/amending-a-single-file-in-a-past-commit-in-git">amending a single file in a past commit in git</a> but unfortunately the accepted solution 'reorders' the commits, which is not what I want. So here's my question:</p>
  
  <p>Every now and then, I notice a bug in my code while working on an (unrelated) feature. A quick <code>git blame</code> then reveals that the bug has been introduced a few commits ago (I commit quite a lot, so usually it's not the most recent commit which introduced the bug). At this point, I usually do this:</p>
  
  <pre><code>git stash                      # temporarily put my work aside
  git rebase -i &lt;bad_commit&gt;~1   # rebase one step before the bad commit
                                 # mark broken commit for editing
  vim &lt;affected_sources&gt;         # fix the bug
  git add &lt;affected_sources&gt;     # stage fixes
  git commit -C &lt;bad_commit&gt;     # commit fixes using same log message as before
  git rebase --continue          # base all later changes onto this
  </code></pre>
  
  <p>However, this happens so often that the above sequence is getting annoying. Especially the 'interactive rebase' is boring. Is there any shortcut to the above sequence, which lets me amend an arbitrary commit in the past with the staged changes? I'm perfectly aware that this changes the history, but I'm doing mistakes so often that I'd really love to have something like</p>
  
  <pre><code>vim &lt;affected_sources&gt;             # fix bug
  git add -p &lt;affected_sources&gt;      # Mark my 'fixup' hungs for staging
  git fixup &lt;bad_commit&gt;             # amend the specified commit with staged changes,
                                     # rebase any successors of bad commit on rewritten 
                                     # commit.
  </code></pre>
  
  <p>Maybe a smart script which can rewrite commits using plumbing tools or so?</p>