Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a version number using git / github

Tags:

I'm using Github, and realized they have a nice little api for accessing repo information like commits, who did it, etc.

This would be a great way to show previous versions of the project on an external site, but I was wondering if there is a known way to add a Version Number to the master commit?

So the version number would either automatically increase with each master commit or I can manually set it.

I know I can add it in the notes, but I'm not familiar if there is a way to separate it.

like image 314
Senica Gonzalez Avatar asked Aug 03 '11 00:08

Senica Gonzalez


People also ask

How do I increment a version number in Git?

By using tags: Tags in Git can be used to add a version number. adds a version tag of v1. 5.0-beta to your current Git repository.

Can GitHub be used for version control?

GitHub — Primary function. Git is a distributed version control system that records different versions of a file (or set of files). It lets users access, compare, update, and distribute any of the recorded version(s) at any time. However, GitHub is mainly a hosting platform for hosting Git repositories online.

What is version number in Git?

GitVersion is a tool that generates a Semantic Version number based on your Git history. The version number generated from GitVersion can then be used for various different purposes, such as: Stamping a version number on artifacts (packages) produced during build.


2 Answers

There are two kinds tags to consider, a build number and a version number. A version number can be applied as a tag by a person when the product ships. This tag is historical and identifies significant events (e.g. shipping the product).

The build number is useful for identifying which build you are on relative to some starting point. The combination of git-tag and git-describe provide a nice means of generating a build number that can be embedded into a build. git-describe can locate a specific previous tag with a glob pattern. The results of git describe will be formatted as:

tagname-[0-9]+-g[0-9a-f]+ 

Where the first pattern is the number of commits from the tag and the second pattern is the hash of the current commit. This can be nicely formatted into a build number. Including the hash (at least the first 7 characters) makes it simple to identify the specific commit associated with the build.

For example, git describe could return release-2.2-42-gd788e0e. This could be formatted to become release-2.2 build 42 (d788e0e).

like image 118
Bill Door Avatar answered Oct 13 '22 08:10

Bill Door


You can use a tag to set a version number. You can read about the tag command on the git tag man page. At work I setup our build server to automatically increment a build version number which is then applied using a tag. I think this will meet your needs?

like image 39
Nathan Fox Avatar answered Oct 13 '22 07:10

Nathan Fox