Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I amend a previous git commit

Tags:

git

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.

like image 492
michael Avatar asked Apr 07 '11 21:04

michael


1 Answers

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.

like image 143
patthoyts Avatar answered Oct 12 '22 10:10

patthoyts