public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* Idea regarding GIT
@ 2026-01-12  2:53 Krzysztof Zabłocki
  2026-01-12 11:04 ` Oswald Buddenhagen
  2026-01-12 22:39 ` brian m. carlson
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Zabłocki @ 2026-01-12  2:53 UTC (permalink / raw)
  To: git@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]

Dear all,
I'm emailing to suggest feature for git. It can be useful for ppl working
with pipelines and having extensive personalized configs. I propose adding
new configuration file (or parameter in .gitconfig) .gittemplates. Files
listed in there had to be indexed before adding them to that file, otherwise
it would work like .gitignore, but difference is if file was added git will
not track changes in it and won't commit them. It can be useful with .env
files, using this feature their empty, template version can be committed and
frozen where local version can be edited. Same with configs requiring local,
machine specific paths. Now there is need to keep template version committed
with different name and proper one recreated locally and ignored which adds
extra work each time. 
Thanks for ur time, lmk ur thoughts.

Kind regards,
Kris

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6032 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Idea regarding GIT
  2026-01-12  2:53 Idea regarding GIT Krzysztof Zabłocki
@ 2026-01-12 11:04 ` Oswald Buddenhagen
  2026-01-12 22:39 ` brian m. carlson
  1 sibling, 0 replies; 3+ messages in thread
From: Oswald Buddenhagen @ 2026-01-12 11:04 UTC (permalink / raw)
  To: Krzysztof Zabłocki; +Cc: git@vger.kernel.org

On Mon, Jan 12, 2026 at 02:53:49AM +0000, Krzysztof Zabłocki wrote:
>I propose adding
>new configuration file (or parameter in .gitconfig) .gittemplates. Files
>listed in there had to be indexed before adding them to that file, otherwise
>it would work like .gitignore, but difference is if file was added git will
>not track changes in it and won't commit them.
>
at first sight this sounds functionally equivalent to "precious" ignored 
files, which was discussed here[1] last time.

[1] https://lore.kernel.org/git/pull.1627.git.1703643931314.gitgitgadget@gmail.com/T/#u


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Idea regarding GIT
  2026-01-12  2:53 Idea regarding GIT Krzysztof Zabłocki
  2026-01-12 11:04 ` Oswald Buddenhagen
@ 2026-01-12 22:39 ` brian m. carlson
  1 sibling, 0 replies; 3+ messages in thread
From: brian m. carlson @ 2026-01-12 22:39 UTC (permalink / raw)
  To: Krzysztof Zabłocki; +Cc: git@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 2850 bytes --]

On 2026-01-12 at 02:53:49, Krzysztof Zabłocki wrote:
> Dear all,
> I'm emailing to suggest feature for git. It can be useful for ppl working
> with pipelines and having extensive personalized configs. I propose adding
> new configuration file (or parameter in .gitconfig) .gittemplates. Files
> listed in there had to be indexed before adding them to that file, otherwise
> it would work like .gitignore, but difference is if file was added git will
> not track changes in it and won't commit them. It can be useful with .env
> files, using this feature their empty, template version can be committed and
> frozen where local version can be edited. Same with configs requiring local,
> machine specific paths. Now there is need to keep template version committed
> with different name and proper one recreated locally and ignored which adds
> extra work each time.

Yeah, you're describing the FAQ entry listed at
https://git-scm.com/docs/gitfaq#ignore-tracked-files.  The rationale
that's given is this:

    The reason is that if Git needs to overwrite this file, such as
    during a checkout, it doesn’t know whether the changes to the file
    are precious and should be kept, or whether they are irrelevant and
    can safely be destroyed.

Even with a `precious` attribute for ignored files, presumably there is
some point at which you want to update the file.  For instance, maybe
the template contains a new, mandatory configuration setting that you
need for your software to work.  However, Git can't possible know when
that situation occurs.

In the case of your `.gittemplates` approach, you have no template file
on disk, only the filled-in file, so there's no way to actually rebuild
the file off the new template.  Your only choice would be to blow away
the file on disk and reset it.  However, with the existing approach, you
can simply run a script (which could even be done in a `post-checkout`
hook if you like) to rebuild the ignored file from the template file,
including whatever information you need or merging the existing data.

It also becomes very complex because Git is absolutely not designed to
have tracked files that are not written into the working tree, so things
like `git reset --hard` would have ambiguous behaviour: do you want to
reset the file to its original state or do you want to preserve it?  If
you want to preserve it, how do you do a full reset of the working tree
to its original state?

At work, we have a standard script for setting up the repository[0], so
it's very easy for anyone to do anything necessary, like generating
these kinds of files or running database migrations.  And again, this
can be done automatically in a hook.

[0] https://github.com/github/scripts-to-rule-them-all
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-12 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12  2:53 Idea regarding GIT Krzysztof Zabłocki
2026-01-12 11:04 ` Oswald Buddenhagen
2026-01-12 22:39 ` brian m. carlson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox