From your question, I think you want something like this.
git-rebase(1) does exactly that.
$ git rebase -i HEAD~5
git awsome-ness contains an example.
- Don't use
git-rebase
on public (remote) commits.
- Make sure your working directory is clean (
commit
or stash
your current changes).
- Run the above command. It launches your
$EDITOR
.
- Replace
pick
before C
and D
by squash
. It will meld C and D into B. If you want to delete a commit then just delete its line.
If you are lost, type:
$ git rebase --abort
However, to copmress the .git folder safely, the above is not recommended. You can try the following as mentioned in a comment by Linus.
git repack -a -d --depth=250 --window=250
where that depth thing is just about how deep the delta chains can be (make them longer for old history - it's worth the space overhead), and the window thing is about how big an object window we want each delta candidate to scan.