1

I have a tag named tag_0.0.1 which is being pushed in the same to Git Repository. I run the build several times a day. Instead of creating new tags every time, I want to rewrite the same tag. New changes should be applied on the existing tag and it can be pushed to the repo. I know we can delete the tag on the repo and create the same in local and push it. Is there any way to apply new commits on the existing tags ?

This is what i tried:

git tag

tag_0.0.1

After code changes -- deleting

git tag -d tag_0.0.1

git push --delete origin tag_0.0.1

Recreating the same and push

git tag tag_0.0.1

git push --tags

I have a feeling about it doesn't make a sense. Is there any better ways ? I also want to know how to push the specific commit instead of pushing all of them.

Emre Acar
  • 920
  • 9
  • 24
Ela
  • 419
  • 1
  • 6
  • 20
  • Git tag is a stamp, it should be used as such. If you don't want to create new tags endlessly, don't create tags at all. Only tag a release or an important milestone. – Madara's Ghost Nov 11 '14 at 09:27
  • You are right. But I wanted to do this as part of build automation. Every build changes should be tagged. so that we can get the specific commit at anytime. Thanks for your response. – Ela Nov 11 '14 at 09:31
  • 1
    You don't need to git tag *every single build* just to get a specific commit. All you need to do is save the commit hash (or first few letters of it) and you can check it out at any time... – Madara's Ghost Nov 11 '14 at 09:32
  • Remember if you checkout a tag, you are in the detached head mode and commits created in this mode are harder to find after you checkout a branch again – gpullen Nov 11 '14 at 09:46

1 Answers1

2

Every build changes should be tagged. so that we can get the specific commit at anytime.

Your build process should rather incorporate the last tag and the current SHA1, using git describe.

You can see an example in "Automatic versioning in Xcode with git-describe" (or even git describe --dirty), using

VERSION=`git describe --dirty |sed -e "s/^[^0-9]*//"`

Other examples:

That way:

  • the binary you are building includes the information allowing you to know what exact version of the code was used to make said build.
  • you limit the tags to the actual versions that count (like a stable version used to make an official release)
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Seems git describe only shows annotated tags. But I create lightweight tags only. Anyway I will give a try. Thanks bunch. – Ela Nov 11 '14 at 11:52