Reputation:
Overview: I want to set automatic (or at least semi-auto) software version numbering in Git.
I want to set some starting version number (like v1.0) to my project. I know, there is tag
for this reason. Googled it and found bunch of materials. For example:
git - the simple guide blog says:
You can create a new tag named 1.0.0 by executing
git tag 1.0.0 1b2e1d63ff
the1b2e1d63ff
stands for the first 10 characters of the commit id you want to reference with your tag.
Kudelabs says:
$ git tag -a 'milestone1' -m 'starting work for milestone 1, due in 2 weeks'
$ git push --tags
I'm really confused. What is difference between first and second method: git tag
and git tag -a
. Can't figure out which to use for this purpose.
How can I set version number in bare remote repo, to which I made 5-6 commits and pushes?
Upvotes: 2
Views: 2336
Reputation: 2284
$ git tag -a -m
is called annotated tag. The value (in "") after the -a
is used as the tag name, while the value after the -m
is used as a tag description message.
Use Tags not a million times (as for buildnumbers)
Increment only time over time.
Automatic tagging workflow:
Depending on your IDE you are using, there is normally an option to run shell commands with each build or ftp-upload or whatever. Use that shell script to run each time you're building your project to check if a new version exists (perhaps defined in your IDE). If so you can run the git command from shell and add a tag.
Here is how to do it in Xcode: https://stackoverflow.com/questions/10091310/heres-how-to-auto-increment-the-build-number-in-xcode Other IDEs maybe handle that thing similarly
Upvotes: 0
Reputation: 209485
Git doesn't have automatic version numbering. You'd have to write your own scripts to do that using git tag
.
If you provide more information about how you want your version numbers to be assigned, we might be able to help further.
Upvotes: 1
Reputation: 28951
git describe
by default uses annotated tags. So, to follow the convention create them annotated (-a
) as Kudelabs says.
Upvotes: 1