Git Reference
Git Reference / Debugging Git itself

20Debugging Git itself

When Git does something you don’t expect, make it show its work.

Trace what Git is doing

Environment variables that turn on detailed logging for a single command.

GIT_TRACE=1 git pull               # commands & aliases run
GIT_TRACE_PERFORMANCE=1 git status # where time goes
GIT_TRACE_SETUP=1 git status       # repo & worktree discovery

Network & auth problems

See the HTTP or SSH conversation with the server.

GIT_CURL_VERBOSE=1 GIT_TRACE_CURL=1 git fetch
GIT_SSH_COMMAND="ssh -v" git fetch
git config --get-all credential.helper

“Where does this setting come from?”

Find which config file sets a value, and what the result is.

git config --show-origin --get pull.rebase
git config --list --show-scope
git var -l | grep -i editor

Is it the alias, hook or Git?

Rule out customisations one by one.

git config --get-regexp '^alias\.'
ls .git/hooks | grep -v sample
git -c core.hooksPath=/dev/null commit   # run without hooks
git --version

Slow repository

Measure first, then tune.

git count-objects -vH
git maintenance run --task=gc
git config core.untrackedCache true
git config feature.manyFiles true

Check repo health

Verify integrity and bundle diagnostics for a bug report.

git fsck --full
git diagnose -o ~/Desktop   # zip of repo stats
git bugreport               # system info template
Read the hintsGit’s error output usually ends with a hint: telling you the exact command to run. git status is the best first step for almost any confusing state.