Daily Archives: 2011-03-02

What to do when you get detached from your head, you git.

I found myself wandering about detached from my head, fully committed. You don’t want to commit when detached from head, but I had.

I didn’t know how it happened, but there I was, headless. What a silly, silly git.

I reached out to a friendly spider and the answer was there in the web.
Before you wander back to your head, it is important to mount yourself to a branch, then you can use that branch to reattach your head quite easily.
Here is how the magic incantations go:

git checkout -b the_wanderer
git rebase master
git checkout master
git merge the_wanderer
git commit

I’ve tied the branch to where I am, then grabbed where I was and attached that, then bound everything back together.
Clear as mud? Already done git checkout master? Check the spellbook that inspired me.