Note that there are some explanatory texts on larger screens.

plurals
  1. PODeriving application build version from `git describe` - how to get a relatively straightforward string?
    primarykey
    data
    text
    <h3>UPDATE</h3> <p>I see that this question has become somewhat popular. It's now years into my admittedly enjoyable Git use, and I have learned a lot since then. <strong>Please</strong>, <strong>pretty please</strong> read the last paragraph before going on about your Git adventures with whatever you will have learned from this Q&amp;A.</p> <hr> <p>I want to compose application build version that is automatically derived from GIT branch name I am on (when building) and the number of commits since the branch "start". I believe this will be unique for any commit in my GIT repository? Branch names are unique, and commits are linked to each other along a branch? If and when I tag a commit, I can also have the version be prefixed with that tag.</p> <p>In a way <code>git describe</code> does what I want, but it does not include the branch name I am on, and it includes abbreviated commit SHA-1 hash, which I don't think I need as it does not add anything to the entropy of the string and may be redundant (I may be wrong here, so please correct me).</p> <p>What are my options? And am I thinking in the right direction here at all? I am just a bit tired of appending numbers to versions when I have more important things to deal with with regards to software development.</p> <p>I never build with a dirty working tree, by the way. I.e. I always commit changes to the repository before building a public release.</p> <p><strong>I am now aware</strong> that Git branches are just commit references, and so, many branches (and tags!) may point to a single commit. Therefore, the question "which branch does this commit belong to / lie on" is not <em>entirely</em> valid with Git. Git <em>does</em> track a "current" branch you're on -- the one it has checked out for you -- but at the same time any number of other branches may be pointing to the same commit and arguably no single branch can be chosen as "main" unless you want to mean the one currently checked out to disk. Please read the <a href="https://stackoverflow.com/questions/3300746/deriving-application-build-version-from-git-describe-how-to-get-a-relatively#answer-3303844">following answer on this page</a> for elaboration.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload