24 September 2011 by Published in: Code No comments yet

Have you ever sworn that you commited feature X, but now can’t find it?  git log shows nothing?

It’s possible that you committed them while you had a detached head.

git status

# Not currently on any branch.

Oops.  And it turns out that not even “git log –all”, you know, shows you all:

–all: Pretend as if all the refs in $GIT_DIR/refs/ are listed on the command line as <commit>.

More like “git log —most“.

If you’re hopelessly trying to figure out where in the world you were, the best way is probably to:

git log -g -9 HEAD

Which will list the last several HEADs you’ve been on.  At this point you can re-capitate yourself with:

git checkout master && git merge DETACHED_HEAD_SHA


Want me to build your app / consult for your company / speak at your event? Good news! I'm an iOS developer for hire.

Like this post? Contribute to the coffee fund so I can write more like it.


Comments are closed.

Powered by WordPress