From: Lars Hjemli Date: Fri, 12 Oct 2007 11:21:58 GMT Subject: Re: RCS keyword expansion Message-ID: <8c5c35580710120421x130c5d7dt6c9d9b5a55313180@mail.gmail.com> In-Reply-To: On 10/12/07, Peter Karlsson wrote: > Johannes said: > > So why not go for the contents? With CVS/SVN you only have the > > chance to do that by date or version number. With git, we have a more > > powerful way: we do it by a hash of the contents. > > Yes, but the hash if of "everything". I'm not interested in > "everything" in this context, and I don't want to have a separate git > repository for each file... Try this: $ echo 'File revision $Id$' > index.html $ echo "*.html ident" > .gitattributes $ git add index.html .gitattributes $ git commit >From now on, the '$Id' in index.html gets expanded to the SHA1 of the content of index.html (not the commit SHA1) each time you checkout (and removed when you commit) If you still want 'last modified date', the closest thing in git is 'commit date' which you can also get for free: $ echo 'Last commit: $Format:%cd$' > index.html $ echo "*.html export-subst" > .gitattributes $ git add index.html .gitattributes $ git commit $ git archive --prefix=test/ HEAD | tar -x $ cat test/index.html For all supported keywords, take a look at the 'git-log --pretty=format' option -- larsh