git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Stamp Git commit id into file during build process

From
Paul Richards <paul.richards@gmail.com>
Date
Jan 16, 2010, 18:50 UTC
Message-ID
<a1138db31001161050i73eade1bif968ca1256dcef2c@mail.gmail.com>

Hi, I am in the process of migrating from Subversion to Git. One thing I am unsure of is how to stamp the 'version' or 'commit id' into a file as part of a build process.

With subversion I used the SubWCRev tool from TortoiseSVN (http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html).

With Git I imagine that I'd like to put a copy of the current commit id (either the full hash or a truncated version of that) into a file which then gets included into the program source code in some way.

Is there a recommended way of doing this with git? Perhaps with something similar to SubWCRev?

Currently I am thinking about using "git log", and grepping the output in some way so that I just get the hash.

Thanks in advance,
-- 
Paul Richards
Next: Erik Faye-Lund
Message 1 of 10 in “Stamp Git commit id into file during build process”
  1. Paul RichardsJan 16, 2010
  2. Erik Faye-LundJan 16, 2010
  3. Erik Faye-LundJan 16, 2010
  4. Sverre RabbelierJan 16, 2010
  5. Erik Faye-LundJan 16, 2010
  6. Sverre RabbelierJan 16, 2010
  7. Jakub NarebskiJan 16, 2010
  8. Paul RichardsJan 16, 2010
  9. Shawn O. PearceJan 16, 2010
  10. Jakub NarebskiJan 16, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.