When git reset misbehaves, debugging without the right logging feels like stabbing in the dark. Most developers use git log for history, but few know how to capture the internal debug output while running git reset. This output shows exactly what Git is doing with your index, working tree, and HEAD at every step.
Enable Git debug logging with:
GIT_TRACE=1 git reset --hard
This sends detailed trace information to stdout. If you need more depth, add GIT_TRACE_SETUP=1 or GIT_TRACE_PERFORMANCE=1 for setup and performance metrics. For file-level changes:
GIT_TRACE=1 GIT_TRACE_SETUP=1 GIT_TRACE_PERFORMANCE=1 git reset --hard <commit>
Pair this with:
GIT_TRACE_PACK_ACCESS=1
GIT_TRACE_PACKET=1
These are invaluable if your reset interacts with remote objects or you suspect corruption in pack files.