12. The reflog remembers where the notes have been
Git logs every move of HEAD and of each branch locally; entries for commits no note reaches last about thirty days; a "lost" commit is recovered by pointing a branch at the name in the log.

12. The reflog remembers where the notes have been

Git logs every move of HEAD and of each branch locally; entries for commits no note reaches last about thirty days; a "lost" commit is recovered by pointing a branch at the name in the log.

It is the safety net under every rewrite and reset.

Every time HEAD or a branch moves, Git writes a line in a diary. The reflog.

Each entry says where the note was, and why it moved. Commit. Checkout. Reset.

You amended, and want the old commit back? It is in the reflog. Point a branch at it.

The diary is local. Yours alone. It stays with your folder. It never travels to another repository.

Entries for commits no note reaches expire after about thirty days. Only after that are those commits removed. Before then, everything is recoverable.

Check yourself. Does the reflog travel with a clone of your repository?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime