Remove / cut off Git's revision / commit history

Assuming master is at commit F:

 # create a new branch with D's content
$ git checkout --orphan temp <d-sha1>
$ git commit

 # rebase everything else onto the temp branch
$ git rebase --onto temp <d-sha1> master

 # clean up
$ git checkout master
$ git branch -d temp

If you want to completely remove the old loose objects (A, B, & C), first make sure you have exactly what you want. This cannot be undone. Once you have confirmed it's what you want, run:

$ git reflog expire --expire=now --all
$ git gc --prune=now

Github has a good article about removing sensitive data (so the commits you want too):

Remove Sensitive Data from Git

Tags:

Git