8

I have made 2 git commit

 $ git log
commit 9613e1e84b42aeef645977272d310250339cf0e0

commit 01f8699be310f9a56a40835b48a922a879bba24f

Each of them touches DIFFERENT FILES. And I have NOT done a push.

But I would like to amend the commit 01f8699be310f9a56a40835b48a922a879bba24f (not the top one). How can I do it?

I know i can use 'git commit --amend' for the amending the top commit. But not the second one.

How can I fix it?

Thank you.

michael
  • 106,540
  • 116
  • 246
  • 346
  • possible duplicate of [How to amend older Git commit?](http://stackoverflow.com/questions/8824971/how-to-amend-older-git-commit) It is marked duplicate but not really a dup IMO. Anyway, see my answer there for what's according to myself the best option. – akostadinov May 01 '15 at 09:08

1 Answers1

10

Use an interactive rebase. git rebase -i HEAD~2 will rebase the last two. You get presented with a list in your editor and can choose to edit just one or more.

patthoyts
  • 32,320
  • 3
  • 62
  • 93