‹ show all tags | rss feed ›

Commit hash replacement in Git archives

tl;dr: use $Format:%h$ in a file and mark for substitution in downloaded archives with 'file export-subst' in .gitattributes

Trying to implement some sort of automatic versioning based on your git commits or tags is not as easy as it should seem. The idea is to use a feature built into the revision control system to modify your project files and increment version counters automatically or embed commit information into software builds - in my case: the --version output of Go applications built with cobra. Ideally, the solution should not require executing some hacked-together scripts or configuring overly many settings on developer machines, yet still embed version information when a user donwloads a release to build locally. read on »