MarcoS
MarcoS

Reputation: 17711

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:

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?

Upvotes: 6

Views: 7156

Answers (2)

Nike Kov
Nike Kov

Reputation: 13718

It's better not to use git push --tags

Use next command in terminal:

tagName=<enter your tag>; git tag $tagName; git push origin tag $tagName

It would create a tag with tagName and push it to remote named origin


Also you can create an alias (function) in bash_aliases:

gtp() {
    git tag $1
    git push origin tag $1
}

Using:

gtp 1.0.0 - will create and push tag 1.0.0 to origin

Upvotes: 0

Igal S.
Igal S.

Reputation: 14543

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.

Upvotes: 17

Related Questions