If a force push or branch deletion occurs, the old object that the ref pointed to may cease to be referenced by any ref and thereby be eligible for garbage collection.
In the duration of the git post-receive hook of such a push, is the old object guaranteed to still be valid?
There is no formal guarantee that the dangling object remains valid, because it is impossible to know when a post-receive hook (or any git
command for that matter) has completed their operation.
The only provision that exists is that garbage collection will give objects a "short lease of life" after they become dangling. "Short" here means two weeks and is configurable. The intent is that this time span will be enough for any ongoing git
command to complete and to have stopped using the dangling objects.