I want to introduce a versioning constant grabbed from the version in Git. I know how to do this -- in a very hackish way in svn --
any ideas on how to do this with Git?
The build number is the number of commits between the current commit and the tag. To guarantee an increasing build number, all these conditions must be satisfied: Make all releases from the same Git repository. Make all releases from the same branch.
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.
Git can be enabled on a specific folder/directory on your file system to version files within that directory (including sub-directories). In git (and other version control systems) terms, this “tracked folder” is called a repository (which formally is a specific data structure storing versioning information).
For me, git describe didn't initially give the hashtag. The following did, however:
git describe --all --long
This results in something of the by kubi described format. Supposing you would only want the last part (hashtag) something like the following would do (saving to version.txt file):
git describe --all --long | tr "-" " " | awk '{ print $3 }' > version.txt
EDIT: As a friend pointed out to me this can actually be done using just cut
instead, if you so desire:
git describe --all --long | cut -d "-" -f 3 > version.txt
Here's what I do:
As part of my build process I run the following script (paraphrased, since I'm not at Xcode right now)
git describe --all > version.txt
Inside my application I read the version number out of this file and display it to the user (when necessary). Make sure you add version.txt to your .gitignore. The benefit of doing it this way is that if you tag your releases git describe
will just output the tag, otherwise it'll output the commit hash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With