On Aug 12, 5:32 am, jd <chima...@gmail.com> wrote:
> I needed to go back in time (a few weeks) for just one subtree of my
> git repository (in order to get rid of some recent changes that were
> no longer wanted). I did the following:
> git checkout <tree-ish> <subtree>
> At first glance, this seemed to do the right thing: the files in the
> subtree were as expected, and the rest of the repository was
> unchanged. I then made some changes in the subtree, did a typical
> commit, made a few more changes elsewhere in the repository, etc.
> However, I eventually noticed that "master" was still set at the same
> place before I performed the previously mentioned checkout.
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
Then, if that master branch was pushed to a remote repo (or repos) you
will have to forcibly update it there, using
$ git push --force remote_name master
for each affected remote.
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