michael
michael

Reputation: 110550

How can I amend a previous git commit

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.

Upvotes: 8

Views: 2868

Answers (1)

patthoyts
patthoyts

Reputation: 33203

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.

Upvotes: 10

Related Questions