<p>Browsing through the git documentation, I can't see anything analogous to SVN's commit hooks or the "propset" features that can, say, update a version number or copyright notice within a file whenever it is committed to the repository.</p>

<p>Are git users expected to write external scripts for this sort of functionality (which doesn't seem out of the question) or have I just missed something obvious?</p>

<p><em>Edit</em> : Just to be clear, I'm more interested in, e.g.,</p>

<pre><code>svn propset svn:keywords "Author Date Id Revision" expl3.dtx
</code></pre>

<p>where a string like this:</p>

<pre><code>$Id: expl3.dtx 780 2008-08-30 12:32:34Z morten $
</code></pre>

<p>is kept up-to-date with the relevant info whenever a commit occurs.</p>

[{'answer_id': 39751, 'author': 'James A. Rosen', 'author_id': 1190, 'author_profile': 'https://Stackoverflow.com/users/1190', 'pm_score': 1, 'selected': False, 'text': "<p>Perhaps the most common SVN property, 'svn:ignore' is done through the .gitignore file, rather than metadata.  I'm afraid I don't have anything more helpful for the other kinds of metadata.</p>\n"}, {'answer_id': 39947, 'author': 'Jordi Bunster', 'author_id': 4272, 'author_profile': 'https://Stackoverflow.com/users/4272', 'pm_score': 5, 'selected': True, 'text': '<p>Quoting from the <a href="https://git.wiki.kernel.org/index.php/GitFaq#Does_git_have_keyword_expansion.3F" rel="noreferrer">Git FAQ</a>:</p>\n<blockquote>\n<p>Does git have keyword expansion?</p>\n<p>Not recommended. Keyword expansion causes all sorts of strange problems and\nisn\'t really useful anyway, especially within the context of an SCM. Outside\ngit you may perform keyword expansion using a script. The Linux kernel export\nscript does this to set the EXTRA_VERSION variable in the Makefile.</p>\n<p>See gitattributes(5) if you really want to do this. If your translation is not\nreversible (eg SCCS keyword expansion) this may be problematic.</p>\n</blockquote>\n'}, {'answer_id': 39981, 'author': 'georg', 'author_id': 3748, 'author_profile': 'https://Stackoverflow.com/users/3748', 'pm_score': 2, 'selected': False, 'text': '<p>Git does have pre-commit and post-commit hooks, they are located inside each .git/hooks directory. Just modify the files and chmod them to make them executable.</p>\n'}, {'answer_id': 78890, 'author': 'emk', 'author_id': 12089, 'author_profile': 'https://Stackoverflow.com/users/12089', 'pm_score': 4, 'selected': False, 'text': '<p>I wrote up a <a href="https://stackoverflow.com/questions/62264/dealing-with-svn-keyword-expansion-with-git-svn#72874">fairly complete answer</a> to this elsewhere, with code showing how to do it. A summary:</p>\n\n<ol>\n<li>You probably don\'t want to do this. Using <code>git describe</code> is a reasonable alternative.</li>\n<li>If you do need to do this, <code>$Id$</code> and <code>$Format$</code> are fairly easy.</li>\n<li>Anything more advanced will require using <code>gitattributes</code> and a custom filter. I provide an example implementation of <code>$Date$</code>.</li>\n</ol>\n\n<p>Solutions based on hook functions are generally not helpful, because they make your working copy dirty.</p>\n'}, {'answer_id': 41815719, 'author': 'superk', 'author_id': 2821963, 'author_profile': 'https://Stackoverflow.com/users/2821963', 'pm_score': 2, 'selected': False, 'text': '<p>Although an age-old Q&amp;A. I thought I\'d throw one in since this has been bugging me for a long time.</p>\n\n<p>I am used to list the files in a directory by reverse-time order (funny me, heh?). The reason is that I would like to see which files I have (or anyone else has) changed recently.</p>\n\n<p>Git will mess my plans because when switching a branch the local repo will completely overwrite the tracked files from the (incremental... I know...) copies that sit in the packed local repo.</p>\n\n<p>This way all files that were checked out will carry the time stamp of the checkout and will not reflect their last modification time..... How so annoying.</p>\n\n<p>So, I\'ve devised a one-liner in bash that will update a $Date:$ property inside any file <strong>WITH THE TIME OF LAST MODIFICATION ACCORDING TO WHAT IT HAS ON FILE SYSTEM</strong> such that I will have an immediate status telling of last modification without having to browse the <code>git log</code> ,  <code>git show</code> or any other tool that gives the commit times in <em>blame</em> mode.</p>\n\n<p>The following procedure will modify the $Date: $ keyword only in tracked files that are going to be committed to the repo. It uses <code>git diff --name-only</code> which will list files that were modified, and nothing else....</p>\n\n<p>I use this one-liner manually before committing the code. One thing though is that I have to navigate to the repo\'s root directory before applying this.</p>\n\n<p>Here\'s the code variant for Linux (pasted as a multi-line for readability)</p>\n\n<pre><code>git diff --name-only | xargs stat -c "%n %Y" 2&gt;/dev/null | \\\nperl -pe \'s/[^[:ascii:]]//g;\' | while read l; do \\\n   set -- $l; f=$1;  shift; d=$*; modif=`date -d "@$d"`; \\\n   perl -i.bak -pe \'s/\\$Date: [\\w \\d\\/:,.)(+-]*\\$/\\$Date: \'"$modif"\'\\$/i\' $f; \\\n   git add $f; done\n</code></pre>\n\n<p>and OSX</p>\n\n<pre><code>git diff --name-only | xargs stat -f "%N %Sm" | while read l; do \\\n   set -- $l; f=$1; shift; d=$*; modif=`date -j -f "%b %d %T %Y" "$d"`; \\\n   perl -i.bak -pe \'s/\\$Date: [\\w \\d\\/:,.)(+-]*\\$/\\$Date: \'"$modif"\'\\$/i\' $f; \\\n   git add $f; done\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/39742', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4161/']