0Pricing
Git Advanced: Monorepo, Submodules & Workflows · Lezione

Reflog per il ripristino

Scopra `git reflog`, la rete di sicurezza per recuperare commit o branch persi e annullamenti accidentali.

Reflog per il ripristino è una lezione Git Advanced: Monorepo, Submodules & Workflows gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Git Advanced: Monorepo, Submodules & Workflows, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Git Advanced: Monorepo, Submodules & Workflows include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Your Git Safety Net

git reflog is a journal of every move your HEAD makes — commit, checkout, merge, rebase, reset. It's a powerful safety net for recovering lost work.

Git's Head & Reference Logs

HEAD points to your current position, and the reflog records everywhere it's been. It lives locally on your machine — not in the shared repo history.

Viewing Your Reflog

Run git reflog to see each action indexed as HEAD@{0}, HEAD@{1}, and so on — with the commit hash, the move, and a timestamp.

git reflog

Deciphering Reflog Output

Read reflog output as a stack: HEAD@{0} is your current state, HEAD@{1} the one before it. Each entry marks where HEAD changed.

Recovering from a Hard Reset

Accidentally ran git reset --hard HEAD~2? Don't panic — those commits aren't gone, just unreachable. The reflog still remembers where HEAD was before the reset.

Using Reflog to Undo Resets

Find the commit before your bad reset in git reflog, then recover it with git reset --hard <hash> — or use the index directly, like HEAD@{2}.

Rescuing a Deleted Branch

Deleted a branch with git branch -D? Its commits still live in your reflog, since HEAD's movements onto that branch were all recorded.

Recreating a Lost Branch

Find the deleted branch's last commit in the reflog, then recreate it: git branch my-feature <hash>. Check it out and you're back in business.

Reflog Expiration

Reflog entries don't last forever: reachable ones expire after 90 days, unreachable ones after 30. It's a safety net, not a backup — always push important work.

Reflog Recovery Quiz

You accidentally ran git reset --hard HEAD~3 and lost your last three commits. You check git reflog and see:

a1b2c3d HEAD@{0}: reset: moving to HEAD~3
e4f5g6h HEAD@{1}: commit: Final bug fix
f7e8d9c HEAD@{2}: commit: Implement new feature
i7j8k9l HEAD@{3}: commit: Initial setup

Which command would restore your repository to the state before the reset, bringing back "Final bug fix" and "Implement new feature"?

Reflog: Your Git Lifesaver

Recap: git reflog logs everywhere HEAD has been, your first defense against bad resets and lost branches. Recover with git reset --hard HEAD@{n} — but it does expire.

Domande Frequenti

La lezione «Reflog per il ripristino» è gratuita?

Sì — il testo completo di «Reflog per il ripristino» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Git Advanced: Monorepo, Submodules & Workflows, passa a CoddyKit PRO. Il corso Git Advanced: Monorepo, Submodules & Workflows include 4 lezioni in totale.

Cosa imparerò in «Reflog per il ripristino»?

Scopra `git reflog`, la rete di sicurezza per recuperare commit o branch persi e annullamenti accidentali. Eserciti Git Advanced: Monorepo, Submodules & Workflows con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Git Advanced: Monorepo, Submodules & Workflows?

Non è richiesta alcuna esperienza precedente. Git Advanced: Monorepo, Submodules & Workflows su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Reflog per il ripristino»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Git Advanced: Monorepo, Submodules & Workflows?

Sì. Ogni lezione Git Advanced: Monorepo, Submodules & Workflows include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Rebase interattivo e modifica dei commit
  2. Stash e cherry-pick delle modifiche
  3. Reflog per il ripristino
  4. Bisect: individuare i commit problematici
← Torna a Git Advanced: Monorepo, Submodules & Workflows