Skip to content

Instantly share code, notes, and snippets.

@treyharris
treyharris / git-ident.md
Last active February 11, 2021 14:22
Why ident attribute doesn't work in Git like CSV/SVN

Why the ident attribute doesn't work in Git like in CVS or SVN

This is a wrinkle that people often don't get about the ident attribute: in CVS or Subversion, it would be legitimate to have a VERSION file containing nothing but $Id$ as a way of tracking that the right push had happened; if you did that with git, you'd get nothing useful. If you run the script below (or just read it and the output that follows), you can see why.

(Please direct comments on this to https://plus.google.com/+TreyHarris/posts/KRgNG3zDk9x.)

How do you do it?

Setting it up in Git is relatively simple. You create (or edit) the file .gitattributes and add a line telling Git to replace $Id$ when found in files that match certain filenames: