修改某个已提交的commit

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

1
$ git rebase --interactive bbc643cd^ 

In the default editor, modify ‘pick’ to ‘edit’ in the line whose commit you want to modify. Make your changes and then stage them with

1
$ git add <filepattern> 

Now you can use

1
$ git commit --amend 

to modify the commit, and after that

1
$ git rebase --continue 

to return back to the previous head commit.