Question: I made 3 'git commit' but I have not done a 'git push'.

```
1. commit 1
2. commit 2
   touches fileA
   touches fileB
   touches fileC
3. commit 3

```

So How can I 

1. roll back changes I made in file b for commit 2? (I can't do a 'git checkout -- fileB' anymore since I already 'git commit', how can i roll back my changes?
2. make changes in fileC and make it like part of commit 2? I think I can go and change the file now and then run a 'git rebase -i HEAD~2' Correct?

Answer: 
Use `git rebase -i HEAD~2` and edit the second commit.
Assuming that you are on branch master and have a clean tree:

```
# checkout incorrect commit
git checkout <sha1_of_commit2>

# revert the changes to fileB by checking out the parent version
git checkout HEAD^ -- fileB

# make an amended commit
git commit --amend

# go back to master
git checkout master

# transplant the changes since the bad commit onto the amended commit
git rebase --onto HEAD@{1} <sha1_of_commit2>

```