Categories
git git-push git-tag

How do you push a tag to a remote repository using Git?

2953

I added a tag to the master branch on my machine:

git tag mytag master

How do I push this to the remote repository? Running git push gives the message:

Everything up-to-date

However, the remote repository does not contain my tag.

0

    302

    To push specific, one tag do following
    git push origin tag_name

    0

      1441

      git push --follow-tags

      This is a sane option introduced in Git 1.8.3:

      git push --follow-tags
      

      It pushes both commits and only tags that are both:

      • annotated
      • reachable (an ancestor) from the pushed commits

      This is sane because:

      It is for those reasons that --tags should be avoided.

      Git 2.4 has added the push.followTags option to turn that flag on by default which you can set with:

      git config --global push.followTags true
      

      or by adding followTags = true to the [push] section of your ~/.gitconfig file.

      5

      • 1

        It was not clear at once for me that it was an and-relation between “annotated” and “reachable from the pushed commits”. I hoped it would push all reachable tags, whatever if annotated or not. Maybe edit to make sure it’s not an OR?

        – Gauthier

        Jun 11, 2015 at 13:00

      • 31

        This doesn’t work for me in git 2.5.0, but git push origin --tags does.

        – nnyby

        Jan 20, 2016 at 19:35


      • @nnyby please provide a minimal example with all necessary commands from repo creation to failure and post it on a gist so I can try to reproduce 😉

        Jan 20, 2016 at 19:44


      • 3

        Thanks for the push.followTags tip. I can’t believe this isn’t the out-of-the-box default. Without it, don’t even bother to tag, you’ll forget and get out of sync tags.

        – moodboom

        May 2, 2016 at 22:38

      • Added a line about setting the follow-tags through the config file.

        – einpoklum

        Jun 26, 2020 at 17:50

      302

      To push specific, one tag do following
      git push origin tag_name

      0