Jhon Piper
Jhon Piper

Reputation: 613

Unable to Push git tags from remote?

I'm trying to create some tags on a local clone and push it to master, and delete a tag from remote and push it to my local clone, to be clear, the remote is github, but were talking about tags, not releases.

I create a tag the tag v0.1-beta on remote. I create a tag v1.0-full-release on local.

I'm noticing that even after a git fetch, git pull, and git push on my local end that nether side see's each others tags.

I looked it up and found that you could use git fetch --tags to fetch tags from remote, so now my local client is up to date. But I can't find a way to push my local v1.0-full-release tag to remote. Git push isn't doing it, and I can't find anything in the documentation.

SideNote: I've done most of my testing in the terminal, but I also notice in both Github for desktop, Kitkracken, and Gmaster that when I created the tag locally, and the other on the remote, fetching or pushing from those clients would't sync the tags ether.

If someone could also explain why it was decided that the standard git fetch, git pull, and git push shouldn't include tags by default, that would also be great.

Upvotes: 1

Views: 1351

Answers (1)

torek
torek

Reputation: 487893

While git fetch does include --tags by default, it doesn't include --tags by default.

(insert record-scratch sound effect here) Wait, what?

OK, the trick is: git fetch will bring over tags when it brings over the commit that has the tag attached to it. There are some variations on the overall theme (or at least, bugs in specific corner cases) in different versions of Git, but in general, if you don't have the tagged commit yet, and you run git fetch without either --tags or --no-tags, you'll get both the commit and the tag. But if you already have the commit, and you run git fetch without --tags, you don't get the tag.

By contrast, git push without --tags never pushes tags, at least if you don't configure various settings. It often makes sense to just run:

git push origin tag-name

to explicitly push one particular tag anyway.

Upvotes: 1

Related Questions