Reputation: 16287
When I run:
git verify-pack -v .git\objects\pack\pack-*.idx
one of the lines in the output contains:
651302358b781ab60f364416272e1c35107c974f blob 23980089 23987383 699599322
But if I try to lookup that blob with:
git rev-list --all --objects | grep 651302358b781ab60f364416272e1c35107c974f
or:
git rev-list --all --reflog --objects | grep 651302358b781ab60f364416272e1c35107c974f
I just get an empty result. Should I not be able to look up any blobs returned by verify-pack
?
Based on below I have tried to: create a fresh clone, run git repack
run git gc
but same result.
Upvotes: 2
Views: 750
Reputation: 1324093
First, I would check if that reference is still in that idx file after
git gc
git repack -Ad # kills in-pack garbage
git prune # kills loose garbage
Use Git 2.32 (Q2 2021) considering:
git repack
is much faster nowgit rev-list
has new options since 2016See commit 14e7b83 (19 Mar 2021), commit 2a15964, commit 13d746a, commit dab3247, commit f25e33c (05 Mar 2021), and commit 0fabafd, commit 339bce2, commit c9fff00, commit f62312e (22 Feb 2021) by Taylor Blau (ttaylorr
).
See commit ccae01c (05 Mar 2021) by Junio C Hamano (gitster
).
See commit 20b031f, commit 6325da1, commit fbf20ae, commit 60bb5f2 (22 Feb 2021) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 2744383, 24 Mar 2021)
revision
: learn '--no-kept-objects'Signed-off-by: Taylor Blau
Reviewed-by: Jeff King
A future caller will want to be able to perform a reachability traversal which terminates when visiting an object found in a kept pack.
The closest existing option is '--honor-pack-keep
', but this isn't quite what we want.
Instead of halting the traversal midway through, a full traversal is always performed, and the results are only trimmed afterwords.Besides needing to introduce a new flag (since culling results post-facto can be different than halting the traversal as it's happening), there is an additional wrinkle handling the distinction in-core and on-disk kept packs.
That is: what kinds of kept pack should stop the traversal?Introduce '
--no-kept-objects[=<on-disk|in-core>]
' to specify which kinds of kept packs, if any, should stop a traversal.
This can be useful for callers that want to perform a reachability analysis, but want to leave certain packs alone (for e.g., when doing a geometric repack that has some "large" packs which are kept in-core that it wants to leave alone).
Note: This is an "internal-use" option only, but interesting to know about, to experiment in your case.
Upvotes: 0
Reputation: 488153
The object may be abandoned, i.e., its last reference(s), whatever they were, are now gone. Because the object is in a pack file, however, it cannot simply be removed. Git must build an entirely new pack.
If you use git repack
to build new pack files, any unreferenced objects will be omitted from the new packs. (Note that git gc
will do this automatically. However, .keep
files may keep the old packs around, if you have created .keep
files.)
Edit: as jthill points out in a comment, you must repack with -a
or -A
to consolidate older packs. While automatic git gc
will supply -A
in some cases, it's only when the number of pack files exceeds gc.autoPackLimit
, which defaults to 50.
Upvotes: 2
Reputation: 2594
I found this at the bottom of git help stash, to find unreferenced commits.
git fsck --unreachable |
grep commit | cut -d\ -f3 |
xargs git log --merges --no-walk --grep=WIP
Upvotes: 0