I have a test repository with a master and test branch. I did make few changes in test branch and did a tagging of the test branch. Then I deleted the test branch (no, I did not merge with master). Surprisingly, when I tried to checkout using the tag which I did earlier, I was able get the test branch which I deleted earlier (of course in DETACHED HEAD state, in "no branch"). How this is possible? Can someone help me understand this??
Git objects are not immediately deleted after operations (for example, they can be recovered with git reflog
). You have to explicitly use git gc
(which calls git prune
too) to manually delete them, or wait an amount of time controlled gc.pruneexpire
to automatically prune them (if that's enabled by gc.auto
).
Besides, objects are permanently deleted only when there's no reference to them, and in this case, you still have a Tag on it, so the commit and its history is preserved.
Check this command output:
git log --oneline --decorate --graph --all
It will give you an overview of your repository, the commits you see here won't be permanently deleted by garbage collector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With