I was kind of freaking out why on earth git diff branch1 branch2
is showing irrelevant things (it was like it's comparing branch1 with an OLDER version of branch2)
Until I found out we have some tags with the same name with a branch!
Other than diff, that makes problems on pull/push (ambiguous ref name error...), and possibly checkout...
So I want to find all these tags so that I can delete them
First, we extract all the tags:
git tag | sort > tags
And branches, if you want to check this with local branches:
git branch | sed -e 's/^[ \t]*//' | sort > branches
Or branches of a specific remote, like origin
git branch -r | grep origin/ | sed -e 's:^[ \t]*origin/::' | sort > branches
After extracting tags and branches (in sorted order), we find the common lines in these 2 files:
comm -1 -2 tags branches > bad-tags
And view the file bad-tags
Then we can delete all of them:
cat bad-tags | xargs git tag -d