I have a number of template files in my git repository which change at different rates. These are then used to generate HTML pages. If someone reports a problem, I want them to
Specify a template that does what you want when cloning, or supply a repo-setup
script and type sh repo-setup
after cloning, or put the necessary commands in a paragraph in the README and say V}!sh
or however your editor pipes commands through the shell, or use git archive
for distribution rather than git push
, since that supports arbitrary keyword substitution. Turning a bare git clone
into a code-injection vector seems like a bad price to pay to avoid trivial inconveniences like this.
As mentioned in git clone, you can setup a template directory which will declare those configuration.
Ie that template folder would have a minimal .gitconfig
with those smudge/clean directives:
filter.manage_date.smudge ${GIT_TEMPLATE_DIR}/smudge-script
filter.manage_date.clean ${GIT_TEMPLATE_DIR}/clean-script
Simply set (export) a GIT_TEMPLATE_DIR
environment variable referencing that template folder.
By using an absolute path starting with ${GIT_TEMPLATE_DIR}
, you won't need to add those scripts to a $PATH
. And that script path can differ from machine to machine: each one can have its own ${GIT_TEMPLATE_DIR}
path.
Finally, the .gitattributes
is part of your repo, so nothing to do there.
With that setup, you can "go to a new computer and clone the repository, all of the clean and smudge is configured automatically."
(provided that new computer has its template-dir pre-populated)