还能对归档做一些简单的关键字替换。在第2章中已经可以看到,可以以–pretty=format形式的简码在任何文件中放入$Format: 字符串。例如,如果想在项目中包含一个叫作LAST_COMMIT的文件,当运行git archive时,最后提交日期自动地注入进该文件,可以这样设置:
echo ‘Last commit date: Format:%cd’ > LAST_COMMIT
echo "LAST_COMMIT export-subst" >> .gitattributes
git add LAST_COMMIT .gitattributes
$ git commit -am ‘adding LAST_COMMIT file for archives’
运行git archive后,打开该文件,会发现其内容如下:
$ cat LAST_COMMIT
Last commit date: $Format:Tue Apr 21 08:38:48 2009 -0700$
REF:http://cwiki.ossez.com/pages/viewpage.action?pageId=7045550