Remove / cut off Git's revision / commit history
git
Solution
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
Problem
I have a project that contains traces to another project of myself that I've used as a kind of a template project. Now I want to remove these traces entirely from the repository. Basically I want to cut off the old junk commits. So I have ``` A -- B -- C -- D -- E -- F ``` and want to get something like ``` D -- E -- F ``` with `A -- B -- C` being completely removed from the repository.