tags:

views:

1406

answers:

3

I usually submit a list of commits for review, so I have a problem:

If I have commit1, commit2,commit3, head.

I know that I can modify head commit with git commit --amend, but how can I modify commit1 that is not head commit.

+1  A: 

Sorry if I am wrong, but from what I understood reading some git tutorials, I think it would be rebase. Interactive mode (-i) might help. Here is a related article which might help:

Jorge Israel Peña
+12  A: 

You can use git rebase, for example, if you want to modify commit bbc643cd, run

$ git rebase bbc643cd^ --interactive

In the default editor, modify 'pick' to 'edit' in the line whose commit you want to modify. Now you can use

$ git commit --amend

to modify the commit, and after that

$ git rebase --continue

to return back to the previous head commit.

ZelluX
Another interesting option within this flow is once you have moved to the commit you want to modify, instead of modifying files and ammed over the commit on top (the one you're editing), you may want to split that commit into two different commits (or even more).In that case, move back to the commit to edit, and run "git reset HEAD^". that will put the modified files of that commit into the stage. Now pick and commit any files as you wish.This flow is quite well explained in "git-rebase" man page. See section "Splitting commits".http://bit.ly/d50w1M
Diego Pino
+2  A: 

http://git.or.cz/gitwiki/GitTips, second tip: "How to change commits deeper in history"

Jakub Narębski