Search code examples
gitgit-tag

Why is my tag pointing to a different commit locally and remotely?


I tagged a commit and git pushed it to origin. Then my colleague moved the tag to a commit he made and pushed. I pulled origin, but when I git log I still see the tag pointing to my commit. When I go to the web interface I can see that the tag points to my colleague's newer commit. I tried git fetch --all and git fetch --tags, to no avail.
Why is my local tag not reflecting the change on origin?


Solution

  • Tags are not expected to move, so by default git fetch is refusing to move the tag. (The output of git fetch should tell you that it rejected the tag update, with a note like "would clobber existing tag".)

    You can force the local tag to update with

    git fetch -f --tags
    

    In general, you should avoid a process in which you routinely move tags.