Search code examples
gitgithubbower

git: create tag and push to remote: why tag is behind master on remote?


I did fork a bower package on github since I need some enhancement and mantainers do not react to pull requests.

I changed a bit bower.json (to change the name, the version and to add myself among the authors), applied my enhancements, added a new tag, and pushed (I need a new tag since bower repository does publish new packages versions on new tags only).
Then I have registered the forked package on the bower repo, with the modified name.

I do not use branches, to avoid complications: everything on master branch (I'm the only developer, and currently the only user of the package...).

So far, everything is good under the sun.

Now, my problem (for sure due to my limited knowledge of git): when I have to make a change on the forked bower package, I do:

  • apply my changes to the sources
  • mark the changes with a tag: git tag -a v1.2.3 -m "my latest enhancement"
  • commit and push: git add -A && git commit -m "committing my latest enhancement" && git push --tags origin master

Then, if I check my repository in github, I see master branch updated (with the latest enhancements), but if I switch to the latest tag (say, "1.2.3"), It is not up-to-date... This way, the changes are not available for bower users (only myself, currently... :-).

How is my work flow flawed?
How my understanding of tags is flawed?


Solution

  • It seems that you tagged first and committed later.

    You should first commit your work, and then when you tag it, it will apply to the latest commit.

    The full flow is:

    • Apply your changes and then:
    • Update bower.json 'version' field

    .

    git add -A
    git commit -m "My changes"
    git tag -a v1.2.3 -m "My last tag"
    git push --tags origin master
    

    You can always use visual tool such as 'gitk' to see where the tag is actually pointing at.