Alex Rivera | Logout

Checking out an old commit and maintaining the head on the master branch?

Asked 2011-04-14T03:47:01.583
91

Currently for switching to another git commit (on the same branch...actually, on the master branch!), I'm executing the command

git checkout ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a

Now, every time I do this git tells me that I'm now with a detached head. How do I go to an older commit and still maintain the head on the same branch?

Edit
Report

1 Answer

200

Most of the time when I do this I checkout to a temp branch:

git checkout -b temp-branch-name ea3d5ed039edd6d4a07cc41bd09eb58edd1f2b3a

Then after I'm done i just delete the branch

answered 2011-04-14T03:54:08.857

Your Answer