I have local commit that are not on any branch that I would like to delete.
I don’t want to rebase them, I really want to delete them, and loose all the content related to these commit.
Is their a command to do so ?
So far I’ve tried interactive rebase as many suggested, but it just move commit around, it doesn’t delete them. I’ve also tried to use reflog delete, but I can’t figure out how to pass a specific commit Id to the command.
Here’s the working tree:
o [master] Commit #6
|
o Commit #5
|
| o Commit #4
|/
o Commit #3
|
o Commit #2
|
o Commit #1
I want to physically delete the commit #4.
If the commit is not referenced by anything, it will be removed with git’s garbage collection, in time.
If you want to force it before hand, use
git gc --prune=now --aggressive