Delete commit history when uncommitting

I had to undo multiple commits by executing git reset --hard HEAD^^^^

.

After git log --all

undoing commits when I run it shows all the commits I made from the beginning. (It doesn't show all deleted commits on startup git log

though) Can I confirm that executing git reset --hard HEAD^^^^

doesn't delete the commit history? Is there any parameter I can add so that commit histories are deleted as well?

+3


source to share


2 answers


Take a look git gc

. The call git gc

will remove any commit object that does not have anyone referencing it (be it a child commit, a branch, or a tag).



+2


source


There is no such thing as "remove commit" in Git. Entries are reachable if they are owned by the branch or otherwise unreachable. git reset --hard HEAD^^^^

moving the current branch 4 completes backwards, hence the 4 commands no longer refer to the current branch. But they can be referenced by other branches (usually the remote-tracking branch if you've already pushed your commits), so you see them in git log --all

.



+1


source







All Articles