* Suggestion: Enhance git init with Language-Specific Templates @ 2025-03-04 11:49 Tech Kenya 2025-03-05 22:43 ` brian m. carlson 0 siblings, 1 reply; 7+ messages in thread From: Tech Kenya @ 2025-03-04 11:49 UTC (permalink / raw) To: git@vger.kernel.org [-- Attachment #1.1: Type: text/plain, Size: 1002 bytes --] I would like to propose an enhancement to git init that allows users to specify a language or framework when initializing a repository, automatically applying an appropriate .gitignore template. Proposal Introduce a flag to git init that enables users to initialize a repository with a predefined .gitignore based on the project's language or framework. For example: git init --golang git init --python git init --node This would generate a .gitignore file using well-established templates, such as those from Toptal's Gitignore Generator https://www.toptal.com/developers/gitignore/ or GitHub's official .gitignore repository. Benefits Improves Developer Experience: Eliminates the manual step of searching for and adding a .gitignore file. Standardization: Ensures that best-practice .gitignore files are consistently applied. Saves Time: Reduces setup time, especially for new projects. Let me know if further details or discussions are needed. Tech Kenya [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 322 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Suggestion: Enhance git init with Language-Specific Templates 2025-03-04 11:49 Suggestion: Enhance git init with Language-Specific Templates Tech Kenya @ 2025-03-05 22:43 ` brian m. carlson 2025-03-05 22:50 ` rsbecker 2025-03-05 22:52 ` Junio C Hamano 0 siblings, 2 replies; 7+ messages in thread From: brian m. carlson @ 2025-03-05 22:43 UTC (permalink / raw) To: Tech Kenya; +Cc: git@vger.kernel.org [-- Attachment #1: Type: text/plain, Size: 2963 bytes --] On 2025-03-04 at 11:49:14, Tech Kenya wrote: > > > I would like to propose an enhancement to git init that allows users to specify a language or framework when initializing a repository, automatically applying an appropriate .gitignore template. > > Proposal > > Introduce a flag to git init that enables users to initialize a repository with a predefined .gitignore based on the project's language or framework. For example: > > git init --golang > git init --python > git init --node > > This would generate a .gitignore file using well-established templates, such as those from Toptal's Gitignore Generator https://www.toptal.com/developers/gitignore/ or GitHub's official .gitignore repository. I think this is an interesting idea, but unfortunately, I think it's going to be practically difficult to implement. You've mentioned three very common languages, but there are a lot of programming languages and even more compiler environments, and it wouldn't be practical for us to try to support them all. For instance, I use Neovim, and the version I'm using ships with 693 different syntax files, which means that there's about 693 different programming languages supported. I was recently exposed at work to some languages that I'd never heard about before and which are not supported by Neovim, and presumably those users would also want similar functionality. That is compounded by the fact that there are a lot of OS- and environment-specific configuration. As an example, a C project on macOS might want to ignore XCode-related files, but for a project that's only on Linux, that wouldn't be necessary. Similarly, that C project might create shared libraries that should be ignored, but those might end up with any of `.so`, `.sl`, `.dylib`, or `.dll` extensions. You mentioned some possible sources for this configuration, but we try not to prioritize specific outside projects. So just because GitHub is widely used and some GitHub employees contribute to Git doesn't mean we give it special precedence or privileges, and we wouldn't want to prioritize their specific collection (or any other), nor would be want `git init` to attempt to make a network connection. We also don't want to maintain this collection ourselves, since it's very project specific. What Git _does_ provide is a way to create a template of objects that should be in the `.git` directory using the `--template` option. It's possible to create a template that contains an initial commit with a `.gitignore` file. I personally would not recommend this approach, since it will not work gracefully with alternate ref formats or hash algorithms, but it is an option for people who want to use it. This was in common use for setting up the default branch name before `git init` added the `-b` option and it's related config, so it is well tested. -- brian m. carlson (they/them or he/him) Toronto, Ontario, CA [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 263 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Suggestion: Enhance git init with Language-Specific Templates 2025-03-05 22:43 ` brian m. carlson @ 2025-03-05 22:50 ` rsbecker 2025-03-05 22:52 ` Junio C Hamano 1 sibling, 0 replies; 7+ messages in thread From: rsbecker @ 2025-03-05 22:50 UTC (permalink / raw) To: 'brian m. carlson', 'Tech Kenya'; +Cc: git On March 5, 2025 5:43 PM, brian m. carlson wrote: >On 2025-03-04 at 11:49:14, Tech Kenya wrote: >> >> >> I would like to propose an enhancement to git init that allows users to specify a >language or framework when initializing a repository, automatically applying an >appropriate .gitignore template. >> >> Proposal >> >> Introduce a flag to git init that enables users to initialize a repository with a >predefined .gitignore based on the project's language or framework. For example: >> >> git init --golang >> git init --python >> git init --node >> >> This would generate a .gitignore file using well-established templates, such as >those from Toptal's Gitignore Generator >https://www.toptal.com/developers/gitignore/ or GitHub's official .gitignore >repository. > >I think this is an interesting idea, but unfortunately, I think it's going to be practically >difficult to implement. You've mentioned three very common languages, but there >are a lot of programming languages and even more compiler environments, and it >wouldn't be practical for us to try to support them all. > >For instance, I use Neovim, and the version I'm using ships with 693 different syntax >files, which means that there's about 693 different programming languages >supported. I was recently exposed at work to some languages that I'd never heard >about before and which are not supported by Neovim, and presumably those users >would also want similar functionality. > >That is compounded by the fact that there are a lot of OS- and environment-specific >configuration. As an example, a C project on macOS might want to ignore XCode- >related files, but for a project that's only on Linux, that wouldn't be necessary. >Similarly, that C project might create shared libraries that should be ignored, but >those might end up with any of `.so`, `.sl`, `.dylib`, or `.dll` extensions. > >You mentioned some possible sources for this configuration, but we try not to >prioritize specific outside projects. So just because GitHub is widely used and some >GitHub employees contribute to Git doesn't mean we give it special precedence or >privileges, and we wouldn't want to prioritize their specific collection (or any other), >nor would be want `git init` to attempt to make a network connection. We also >don't want to maintain this collection ourselves, since it's very project specific. > >What Git _does_ provide is a way to create a template of objects that should be in >the `.git` directory using the `--template` option. It's possible to create a template >that contains an initial commit with a `.gitignore` file. I personally would not >recommend this approach, since it will not work gracefully with alternate ref >formats or hash algorithms, but it is an option for people who want to use it. This >was in common use for setting up the default branch name before `git init` added >the `-b` option and it's related config, so it is well tested. One way to deal with this is to add language-specific descriptors. What I did in my own front end is to provide a set of regex patterns that define the relevant portions of the languages and extensions. This allows my end-users to add their own languages and leave me out of it completely. It might be workable if we have a quantified extensible language structure for this. Otherwise, this might be DOA. --Randall ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Suggestion: Enhance git init with Language-Specific Templates 2025-03-05 22:43 ` brian m. carlson 2025-03-05 22:50 ` rsbecker @ 2025-03-05 22:52 ` Junio C Hamano 2025-03-05 23:53 ` Oleg Taranenko 1 sibling, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2025-03-05 22:52 UTC (permalink / raw) To: brian m. carlson; +Cc: Tech Kenya, git@vger.kernel.org "brian m. carlson" <sandals@crustytoothpaste.net> writes: > What Git _does_ provide is a way to create a template of objects that > should be in the `.git` directory using the `--template` option. It's > possible to create a template that contains an initial commit with a > `.gitignore` file. I personally would not recommend this approach, > since it will not work gracefully with alternate ref formats or hash > algorithms, but it is an option for people who want to use it. This was > in common use for setting up the default branch name before `git init` > added the `-b` option and it's related config, so it is well tested. I wouldn't have thrown objects in the --template directory, and I wouldn't count on things outside what the mechanism was invented for (namely, .git/hooks and possibly .git/info/ files) would forever be copied in newer versions of Git, but certainly "git init --template" mechanism sounds like a good escape hatch than mucking with Git code base to teach it myriad of languages and their dialects. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Suggestion: Enhance git init with Language-Specific Templates 2025-03-05 22:52 ` Junio C Hamano @ 2025-03-05 23:53 ` Oleg Taranenko 2025-03-05 23:56 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Oleg Taranenko @ 2025-03-05 23:53 UTC (permalink / raw) To: Junio C Hamano; +Cc: brian m. carlson, Tech Kenya, git@vger.kernel.org On Wed, 5 Mar 2025 at 23:53, Junio C Hamano <gitster@pobox.com> wrote: > I wouldn't have thrown objects in the --template directory, and I > wouldn't count on things outside what the mechanism was invented for > (namely, .git/hooks and possibly .git/info/ files) would forever be > copied in newer versions of Git, but certainly "git init --template" > mechanism sounds like a good escape hatch than mucking with Git code > base to teach it myriad of languages and their dialects. It sounds like creating a copy of the .gitignore structure requires the user to learn bash script syntax. :-D I'd like to suggest adding one more option to the init --template <template/dir> --only-gitignores. It will not deal with all the complicated mechanics behind hooks/etc, and will only look at the template folder structure and copy **/.gitignore into the newly created worktree. In case of existing .gitignore files, just put warnings and do not override those. --Oleg ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Suggestion: Enhance git init with Language-Specific Templates 2025-03-05 23:53 ` Oleg Taranenko @ 2025-03-05 23:56 ` Junio C Hamano 2025-03-06 0:04 ` Oleg Taranenko 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2025-03-05 23:56 UTC (permalink / raw) To: Oleg Taranenko; +Cc: brian m. carlson, Tech Kenya, git@vger.kernel.org Oleg Taranenko <olegtaranenko@gmail.com> writes: > On Wed, 5 Mar 2025 at 23:53, Junio C Hamano <gitster@pobox.com> wrote: > >> I wouldn't have thrown objects in the --template directory, and I >> wouldn't count on things outside what the mechanism was invented for >> (namely, .git/hooks and possibly .git/info/ files) would forever be >> copied in newer versions of Git, but certainly "git init --template" >> mechanism sounds like a good escape hatch than mucking with Git code >> base to teach it myriad of languages and their dialects. > > It sounds like creating a copy of the .gitignore structure requires > the user to learn bash script syntax. :-D I'd like to suggest adding > one more option to the init --template <template/dir> > --only-gitignores. It will not deal with all the complicated mechanics > behind hooks/etc, and will only look at the template folder structure > and copy **/.gitignore into the newly created worktree. In case of > existing .gitignore files, just put warnings and do not override > those. I was referring to .git/info because of the .git/info/excludes file. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Suggestion: Enhance git init with Language-Specific Templates 2025-03-05 23:56 ` Junio C Hamano @ 2025-03-06 0:04 ` Oleg Taranenko 0 siblings, 0 replies; 7+ messages in thread From: Oleg Taranenko @ 2025-03-06 0:04 UTC (permalink / raw) To: Junio C Hamano; +Cc: brian m. carlson, Tech Kenya, git@vger.kernel.org On Thu, 6 Mar 2025 at 00:56, Junio C Hamano <gitster@pobox.com> wrote: > I was referring to .git/info because of the .git/info/excludes file. .git/info/excludes is a great feature, but it often needs to persist ignored structure, for example, in case of creating a zillion small projects/repos for the learning process. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-03-06 0:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-03-04 11:49 Suggestion: Enhance git init with Language-Specific Templates Tech Kenya 2025-03-05 22:43 ` brian m. carlson 2025-03-05 22:50 ` rsbecker 2025-03-05 22:52 ` Junio C Hamano 2025-03-05 23:53 ` Oleg Taranenko 2025-03-05 23:56 ` Junio C Hamano 2025-03-06 0:04 ` Oleg Taranenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).