Hacker News new | past | comments | ask | show | jobs | submit login

git reflog is my favorite

I used reflog for the first time a few days ago. I rebased a branch, and somewhere i messed up the conflict resolution, so I wanted to undo the rebase. It was surprisingly easy!

reflog is one of these things where you think "that would have been awesome to have" in hindsight.

In 2009 or so, I was using git-svn on the KDE SVN. I was preparing a major refactoring of Kolf in a local branch (about 60 commits with 10000 lines changed), and pushed it to the SVN once I was satisfied with it.

Unfortunately, the 20th-or-so commit failed because a SVN pre-commit hook rejected it (there were some DOS line-endings in a source file that I imported). At that time, git-svn was (AFAIR) already prepared to handle a failing SVN pre-commit hook on the first commit (e.g. when authorization is missing or stuff like that), but not somewhere in the middle.

The end result was that my working copy, my index, and my master branch was completely trashed. And I didn't have a backup... Luckily, the tip commit of my feature branch had not yet been packed, so a clever grep on .git/objects found it, and I could recover my pre-push state.

Since then, reflog has always been enabled on my systems. Luckily, I haven't needed it since.

Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact