Reputation: 505
It seems odd to me this behavior, I have a git tag, lets say tag-a, when I checked it out by running the following:
git checkout tag-a
it checks out tag-b
user@server xxx ~/path/git-local-folder ((tag-b))
I would guess there is some sort of relationship between tag-a and tag-b but I don't know what it is and the logic of it
Upvotes: -1
Views: 383
Reputation: 97908
The "git checkout" command has several modes of operation, which it selects automatically based on the kind of argument you give it. The ones relevant right now are:
Note that the newer "git switch" command forces you to make this distinction explicitly: if the argument is not a branch name, it will fail unless you specify the --detach
option.
Now, when your prompt tries to display the currently checked out branch, the simplest place to look is in the HEAD file. But if you are in a "detached HEAD" state, that will just contain a commit hash, regardless of how you chose that commit. So the display code has to pick something to show instead of the branch name. It can look if there are any tags pointing at the currently checked out commit, but if there is more than one tag pointing at it, it doesn't know which one you used, and just has to guess.
In your case, "tag-a" and "tag-b" presumably reference the same commit. So once you check out that commit, the prompt you're using looks for a tag, and finds "tag-b", even when what you actually typed was "tag-a", or even the commit hash.
Upvotes: 1