Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - get rid of unreachable commit

Tags:

git

I am trying to cleanup my repository and remove everything unreachable.

I did

git reflog expire --expire=now --all
git fsck --full --unreachable
git repack -A -d
git gc --aggressive --prune=now

But I still have some commits that are unreachable from my understanding but not by git's

I have some commit, let's say A

git branch --all --contains A
git tag --contains A

return nothing

but

git fsck --full --unreachable

also returns nothing so it does not consider A as an unreachable.

What am I missing?

like image 511
mnaoumov Avatar asked Oct 19 '22 23:10

mnaoumov


1 Answers

Actually, I found it!

That is refs/original/mybranch ref that still keep my commit reachable.

These original refs are created during git filter-branch

git branch --all

does not include them.

The reason why I did not find them at the beginning because they were missing in .git/refs/original folder.

I found them in .git/packed-refs file. I just removed those branches from that file and cleaned repository again.

like image 74
mnaoumov Avatar answered Oct 24 '22 10:10

mnaoumov