On Aug 12, 9:09 pm, jd <chima...@gmail.com> wrote:
> > That's because you created a situation known as "detached HEAD".
> > > How can I fix this? I want "master" to point to the same place as HEAD.
> > Record the name of the commit HEAD points at, checkout master and
> > "hard reset" it to that commit. The simplest way to do that is via a
> > branch or tag:
> > $ git tag foo
> > $ git checkout master
> > $ git reset --hard foo
> > $ git tag -d foo
> Thank you for the help, that seems to have fixed the problem.
> One question: why is the "git checkout master" needed? (What would
> have happened if I had done the hard reset when the "detached head"
> was checked out?)
Since "foo" would point to the same commit as HEAD, the reset command
would just remove any uncommitted changes in your working tree, if
any; otherwise this reset would be a no-op as you reset HEAD to the
point it points to.
In other words, git-reset resets what is currently checked out, and
its "commit-ish" argument should be interpreted as answering the
question "reset to what commit?", not "what to reset?".
Hence, you wanted to reset master's tip to point to a different
commit, so you checked out master and then reset it (made its tip
point to the commit "foo" pointed to).
Reading through man pages for git-reset and git-rev-parse is highly
advised for understanding of the ideas being involved.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at