Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete commit history when undoing commits

Tags:

git

I had to undo a few commits by doing git reset --hard HEAD^^^^.

After undoing the commits, when I ran git log --all, it shows all the commits I have done from the beginning. (It doesn't show all the deleted commits when I run git log though) Can I confirm that doing git reset --hard HEAD^^^^ doesn't delete the commit history? Is there any option I can add so that the commit histories are erased as well?

like image 655
Faizal Ismaeel Avatar asked Jul 14 '26 11:07

Faizal Ismaeel


1 Answers

Have a look at git gc. Invoking git gc will remove any commit object that does not have anyone referencing it (be it a child commit, a branch or a tag).

like image 175
Madara's Ghost Avatar answered Jul 19 '26 15:07

Madara's Ghost



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!