Some background:
I currently have two local git repos which point to the same origin/master project. The reason I have two git repos is so that I have a clean master copy that I can use whenever I need and the one copy which my sandbox where I can apply changes, commit, etc. It is probably overkill, but there are some advantages for me personally by having a duplicate local git copy.
A co-worker originally created a lightweight tag for 1.0.2, but we deleted it and re-tagged it as an annotated version with the same number. They committed the change via git push to the remote repo. I pulled down the latest changes on both my local git instances.
Our tags are as follows:
release-1.0.0
release-1.0.1
release-1.0.2
The Problem:
Here is the issue I can't figure out. My sandbox repo shows the latest tag version (release-1.0.2) when I run "git describe". This is what I expected. However, the clean repo copy, which I only do pulls from, shows the older tag (release-1.0.1) when I execute "git describe". I verified that both are pointing to the origin master. I did some more research and found an overstack solution that pointed me to running "git cat-file -t". Here is the difference I noticed:
git cat-file -t release-1.0.1 --> tag
git cat-file -t release-1.0.2 --> commit
Why is my clean copy repo showing an older tag version when I run "git describe" unlike my sandbox repo? I can confirm that I can see release-1.0.2 listed if I run "git describe --tags" on the clean repo copy.
Unless you use the
--tagsflag,git describeis only concerned with annotated (as opposed to lightweight) tags. Here, the output ofgit cat-fileindicates that you still have the oldrelease-1.0.2lightweight tag in your sandbox repo. The snag is that, by default,git pullitself will not fetch the newer, annotated tag of the same name and overwrite the older, lightweight one with it.To solve the problem, first delete the lightweight tag locally by running
in your sandbox repo, and then, run
(or
git pull, if you know what you're doing). The newrelease-1.0.2annotated tag will then take the place of the old lightweight one. You can make sure of that by runninggit describeorwhich should now output
tag(notcommit).