I am using a git repo with a checkout on a tag version1. I create a new tag version2 and then checkout to it. But git status keeps reporting version1. This is probably a git optimization but an uncomfortable one.
Here is an actual session:
C:\example>git status
HEAD detached at version1
nothing to commit, working tree clean
C:\example>git tag version2
C:\example>git checkout version2
HEAD is now at 736b51b 'commit'
C:\example>git status
HEAD detached at version1
nothing to commit, working tree clean
It is annoying for me because our product is composed of several components, each with its git repository. Between two product relesase, some components may stay identical, hence the need to tag a given commit with two different versions. But when checking if all the tag were correctly set for the version2 release, it is very annoying that git hides this information.
The git version used:
C:\example>git --version
git version 2.24.1.windows.2
CodePudding user response:
The "detached at" and "detached from" messages rely on clues that git checkout leaves behind in the HEAD reflog. They are not reliable and you must not rely on them. But if you want git status to provide the information you're looking for more often, you can get that: simply check out (git switch or git checkout) some named branch between the check-out operations on tags. This will update the HEAD reflog in such a way that the clues are there more often.
