A Git commit stores a pointer to a snapshot of tracked files, along with parent commit references and metadata; it does not store a patch. Git objects are immutable after creation, but that does not mean they stay forever: if no ref or reflog protects an object, Git may eventually prune it. “Git never deletes anything” is a shorthand for immutability, not a retention guarantee.
What does a Git commit actually store?
A commit object points to a root tree that describes the tracked project state. It also records its parent commit or commits and metadata. The tree contains directory entries with names, modes, object types and object IDs. An entry can point to a blob for a file or symbolic link, another tree for a directory, or a commit object for a submodule.
As an Amazon Associate I earn from qualifying purchases.
A blob holds file contents. If a commit changes only two files, Git can create new blobs for those files while reusing the existing object IDs for unchanged files. The snapshot model therefore does not require a full duplicate copy of every file for every commit. The snapshot covers tracked state, not untracked files sitting in a working directory.
The object ID identifies an object’s contents under the repository’s Git object format. Git’s current core data model manual states: “Git objects never change after they’re created.” That describes whether an object is modified in place; it does not promise permanent retention.
#1 Best Overall
Does Git store a snapshot or a diff?
Git stores the commit’s tree snapshot, not the diff as the commit’s payload. When Git displays what changed, it compares the commit’s tree with a parent tree. As the Git data model manual puts it: “Git does not store the diff for a commit: when you ask Git to show the commit with git-show[1], it calculates the diff from its parent on the fly.”
This is why a displayed patch is a view of the difference between two snapshots rather than a stored ingredient of the commit. A merge commit can have more than one parent, so the comparison shown can depend on which parent or diff view is used.
Rank #2
What happens when you delete a file?
When a file deletion is committed, the new tree simply has no entry for that path. The earlier commit still points to its earlier tree, which can still point to the blob containing the file’s contents. Deleting a file from the current version therefore does not remove it from earlier retained history.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →“Deleted in the latest commit” and “removed from every retained copy” are different outcomes. If sensitive content was committed, a later deletion alone does not erase it from prior commits. Rewriting history may be needed to remove it from the history you control, and collaborators may need to update their clones. Local Git’s object model does not establish what a hosting provider or its backups retain.
Do reset, amend, and rebase delete old commits?
These operations can change which commits are named by current branch tips, but they do not edit old commit objects in place. git commit --amend and rebase create replacement history. Reset or another ref move can leave earlier commits unreachable from the branch that used to point to them.
Unreachable means an object is no longer reachable from the relevant refs; it does not necessarily mean it has already been erased. Another branch, tag, remote-tracking ref, other name under refs/*, or reflog entry may still provide a path to it. The git-reflog manual describes reflogs as records of updates to references.
Recovery after history changes may be possible through a reflog or another ref, but it is not guaranteed. Reflogs expire, repository settings differ, and maintenance may already have removed unprotected objects. The Git glossary defines reachability-related terms used to describe this object graph.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
When can Git garbage collection prune objects?
Git maintenance can remove objects that are no longer protected, but git gc is not a deterministic command that immediately deletes everything unreachable. The git-gc manual says: “git gc tries very hard not to delete objects that are referenced anywhere in your repository.” It also documents cleanup of unreachable objects.
Best Value
The online manual documents defaults equivalent to pruning loose objects older than two weeks, and expiration defaults of 30 days for unreachable reflog entries and 90 days for ordinary reflog entries. These are configurable defaults, not a promise that a particular commit will remain recoverable for those exact periods. Reachability, object age and storage form, configured expiration rules, and repository activity can all matter. Check the installed Git version and local configuration for repository-specific behavior.
Packing stores objects together to reduce space and improve performance; it does not rewrite the logical objects or their history. Unreachable packed objects may remain unless repacking handles them, as described in the Git User Manual. The gc manual warns that pruning immediately with --prune=now increases the risk of problems if another process is writing to the repository at the same time.
How to think about whether an old commit is still recoverable
There is no single age-based answer. The relevant questions are which references still lead to the object, whether a reflog entry protects it, whether it is loose or packed, and what expiration and pruning rules are configured. A local repository and a hosted copy are separate cases: the local object lifecycle cannot tell you a host’s backup or erasure policy.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




