why to update these commits into whatever branch they are in?
That's just it: you are not on any branch but currently working on a detached head:
starting from version 1.5.0, the above command detaches your HEAD
from the current branch and directly points at the commit named by the tag.
You might see it if you do a gitk --all
One way to fix it (if you have committed everything)
$ git log -1
# note the SHA-1 of latest commit
$ git checkout master
# reset your branch head to your previously detached commit
$ git reset --hard <commit-id>
Another way would be to merge your work into the current master HEAD which happens to be at the tag:
$ git checkout -m 0.42
but that looses the history of your commits made on a detached HEAD.
I gather this happened when I checked out tag 0.42. Why is that not the same as master? (I had tagged the master in its latest state)
No it is not the same than master. As Jefromi points out in the comments, branch can move (or be renamed, or deleted, or...)
master
was referring to the same commit than the '0.42' tag, but that won't be always the case.
With a checkout of a tag, you do not checkout a branch, hence the 'detached HEAD' state.
Note: as mentioned in this SO answer, the @{1}
notation you see is $(git symbolic-ref HEAD)@{1}
, i.e. it is uses reflog for current (here detached) branch, not HEAD reflog.