Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are not the first one to think about a <a href="http://wincent.com/a/about/wincent/weblog/archives/2007/07/build_numbers_i.php" rel="nofollow noreferrer">"revision number" in Git</a>, but '<code>wc</code>' is quite dangerous, since commit can be erased or squashed, and the history revisited.</p> <p>The "revision number" was especially important for Subversion since it <a href="http://macresearch.org/whos-git" rel="nofollow noreferrer">was needed in case of merge</a> (SVN1.5 and 1.6 have improved on that front).</p> <p>You could end up with a pre-commit hook which would include a revision number in the comment, with an algorithm <em>not involving</em> looking up the <em>all</em> history of a branch to determine the correct number.</p> <p><a href="http://jameswestby.net/weblog/2008/Mar" rel="nofollow noreferrer"><strong>Bazaar</strong></a> actually came up with <a href="http://thread.gmane.org/gmane.comp.version-control.bazaar-ng.general/38388" rel="nofollow noreferrer">such an algorithm </a>, and it may be a good starting point for what you want to do.</p> <p>(As <a href="https://stackoverflow.com/questions/677436/how-to-get-the-git-commit-count/677566#677566">Bombe's answer</a> points out, Git has actually an algorithm of its own, based on the latest tag, plus the number of commits, plus a bit of an SHA-1 key). You should see (and upvote) his answer if it works for you.</p> <hr> <p>To illustrate <a href="https://stackoverflow.com/questions/677436/how-to-get-the-git-commit-count/677529#677529">Aaron's idea</a>, you can also <a href="http://www.stompy.org/2008/08/14/xcode-and-git-another-build-script/" rel="nofollow noreferrer">append the Git commit hash into an application’s "info" file</a> you are distributing with your application.</p> <p>That way, the about box would look like:</p> <p><img src="https://i.stack.imgur.com/xPr0b.png" alt="About box"></p> <p>The applicative number is part of the commit, but the 'application’s "info" file' is generated during the packaging process, effectively linking an <em>applicative</em> build number to a technical revision <em>id</em>.</p>
 

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