DEV Community

Discussion on: Git Commands ( to ease your development 🤗 )

Collapse
 
nstvnsn profile image
Nathan Stevenson • Edited

Let me introduce you to git reflog!

While git log shows us the repository's public commit history, git reflog (or git reference log) shows us our workplace-specific local commit history.

I'll tell you why this is important.

Ever accidentally mess up a rebase and lose everything in the last few commits? You check you log and there's no trace of the last several hours worth of work to be found? Oops

With reflog, no problemo. It will shown you those commits you thought were gonezo. Run the command, identify the latest commit, make note of the branch tip and run:

git reset --hard my-branch-tip-before-rebase

A sanity saver, for sure. Learned from experiencing my own moment of panic.