Da Anonimo (non verificato) , 29 Aprile 2026

Cos'e un ref

Un ref e un nome che punta a un oggetto — di solito un commit. I branch sono ref sotto refs/heads/, i tag sotto refs/tags/, remote-tracking sotto refs/remotes/, e pseudo-ref come HEAD, FETCH_HEAD, ORIG_HEAD.

Ispezionare i ref

git for-each-ref
git for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:relative)' refs/heads
git symbolic-ref HEAD
git update-ref refs/heads/foo <sha>

Il reflog

git reflog
git reflog show feature
git reflog show HEAD@{2.weeks.ago}
git log -g --oneline
git checkout HEAD@{1}
git branch rescue HEAD@{5}

Scadenza del reflog

git config gc.reflogExpire never
git config gc.reflogExpireUnreachable 60.days

Pseudo-ref speciali

HEAD, ORIG_HEAD, FETCH_HEAD, MERGE_HEAD.

Backend reftable

git init --ref-format=reftable

Errori comuni

Confidare nel reflog per sempre: scade. Modificare .git/refs/ a mano: usare git update-ref.