I am trying to clean a repo:
local FIRST_COMMIT="bf450342272a94117d78eae34a140a2a39359dad"
git branch -d bad-master
git remote remove bad-remote
git rev-parse ${FIRST_COMMIT} > .git/shallow
git fsck --unreachable
git gc --prune=now
The idea is the following:
- keep a single branch (the
develop) branch - remove all unwanted references
- cut the history in the
developbranch, with.git/shallow/gc --prune
After doing this, I have verified the following:
- there are no remotes defined
- there are no tags defined
- there is a single branch:
develop - the history in the
developbranch is indeed reduced up to the specified commit
But there is still a problem:
git rev-list --all
Lists commits which are not reachable through the develop branch!
I do not understand why git fsck --unreachable does not list that, and why git gc --prune=now does not remove those commits. The only explanation is that those commits are reachable, through other references. Which ones?
How can I identify how a given commit is reachable?
What I expect is:
- identify a reference which I was missing up to now (branch / remote / tag / ???)
- remove that reference
- after that,
prunewill remove the unwanted commits.