Git: how to remove history before a specific commit

Easiest way is with a git graft. If you edit the file .git/info/grafts, you can put lines in the file of the format

[ref] [parent1] [parent2] ...

Any commits referenced on the left side are then treated as if the parents listed on the right are the parents of that commit. So you can insert a line like

c1000

and it will be treated as though it has no parents. This can then be "baked in stone" by running git-filter-branch.


I have found the below useful for creating new repos with a different root ( which is what I think you are asking when you say remove history before a commit):

git fast-export master~5..master | (cd ../newrepo.git && git init . && git fast-import && git checkout)

(you can do the above in the same repo too)