gitversion-controlrcs

Git: Can I get the equivalent of an RCS $Id$ string?


I have a program that is distributed as a single file, and doesn't go through an installation procedure.

Is there a way to have git embed an RCS-like $Id$ string? Checkin timestamp, etc, would also be fine, just something to easily id files in the field. Github-specific solutions are acceptable.


Solution

  • Git support keyword expansion for $Id$ which will be replaced with the SHA value of the file when you do a git checkout. If this is not sufficient you can write a custom content filter. For more details see https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#Keyword-Expansion