{"thread":{"id":"63056","subject":"Suggestion: Enhance git init with Language-Specific Templates","startedAt":"2025-03-04T11:49:27Z","lastAt":"2025-03-06T00:04:38Z","messageCount":7,"participants":["Tech Kenya","brian m. carlson","rsbecker@nexbridge.com","Junio C Hamano","Oleg Taranenko"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"513529","messageId":"qMn1k_iuZCe353x0BBxdD5z4-17Abk_ZHoPr8nVDLOgLhGf8Nxb3-bsXPH2GiATUsuGLVqAaEESua5G9qBaW0qqxwz-7AbcNyRwSXJzbKMs=@protonmail.com","threadId":"63056","inReplyTo":null,"subject":"Suggestion: Enhance git init with Language-Specific Templates","fromName":"Tech Kenya","fromEmail":"techkenya@protonmail.com","sentAt":"2025-03-04T11:49:14Z","receivedAt":"2025-03-04T11:49:27Z","isPatch":false,"sender":{"key":"techkenya@protonmail.com","avatar":null},"body":"\n\nI 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.\n\nProposal\n\nIntroduce 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:\n\ngit init --golang\ngit init --python\ngit init --node\n\nThis 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.\n\nBenefits\n\nImproves Developer Experience: Eliminates the manual step of searching for and adding a .gitignore file.\n\nStandardization: Ensures that best-practice .gitignore files are consistently applied.\n\nSaves Time: Reduces setup time, especially for new projects.\n\nLet me know if further details or discussions are needed.\n\nTech Kenya\n\n\n\n"},{"id":"513619","messageId":"Z8jTjt1CQ7hp8KSP@tapette.crustytoothpaste.net","threadId":"63056","inReplyTo":"qMn1k_iuZCe353x0BBxdD5z4-17Abk_ZHoPr8nVDLOgLhGf8Nxb3-bsXPH2GiATUsuGLVqAaEESua5G9qBaW0qqxwz-7AbcNyRwSXJzbKMs=@protonmail.com","subject":"Re: Suggestion: Enhance git init with Language-Specific Templates","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-03-05T22:43:26Z","receivedAt":"2025-03-05T22:43:34Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-03-04 at 11:49:14, Tech Kenya wrote:\n> \n> \n> 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.\n> \n> Proposal\n> \n> 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:\n> \n> git init --golang\n> git init --python\n> git init --node\n> \n> 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.\n\nI think this is an interesting idea, but unfortunately, I think it's\ngoing to be practically difficult to implement.  You've mentioned three\nvery common languages, but there are a lot of programming languages and\neven more compiler environments, and it wouldn't be practical for us to\ntry to support them all.\n\nFor instance, I use Neovim, and the version I'm using ships with 693\ndifferent syntax files, which means that there's about 693 different\nprogramming languages supported.  I was recently exposed at work to some\nlanguages that I'd never heard about before and which are not supported\nby Neovim, and presumably those users would also want similar\nfunctionality.\n\nThat is compounded by the fact that there are a lot of OS- and\nenvironment-specific configuration.  As an example, a C project on macOS\nmight want to ignore XCode-related files, but for a project that's only\non Linux, that wouldn't be necessary.  Similarly, that C project might\ncreate shared libraries that should be ignored, but those might end up\nwith any of `.so`, `.sl`, `.dylib`, or `.dll` extensions.\n\nYou mentioned some possible sources for this configuration, but we try\nnot to prioritize specific outside projects.  So just because GitHub is\nwidely used and some GitHub employees contribute to Git doesn't mean we\ngive it special precedence or privileges, and we wouldn't want to\nprioritize their specific collection (or any other), nor would be want\n`git init` to attempt to make a network connection.  We also don't want\nto maintain this collection ourselves, since it's very project specific.\n\nWhat Git _does_ provide is a way to create a template of objects that\nshould be in the `.git` directory using the `--template` option.  It's\npossible to create a template that contains an initial commit with a\n`.gitignore` file.  I personally would not recommend this approach,\nsince it will not work gracefully with alternate ref formats or hash\nalgorithms, but it is an option for people who want to use it.  This was\nin common use for setting up the default branch name before `git init`\nadded the `-b` option and it's related config, so it is well tested.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"513620","messageId":"00a201db8e21$04d42ac0$0e7c8040$@nexbridge.com","threadId":"63056","inReplyTo":"Z8jTjt1CQ7hp8KSP@tapette.crustytoothpaste.net","subject":"RE: Suggestion: Enhance git init with Language-Specific Templates","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2025-03-05T22:50:34Z","receivedAt":"2025-03-05T22:50:53Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On March 5, 2025 5:43 PM, brian m. carlson wrote:\n>On 2025-03-04 at 11:49:14, Tech Kenya wrote:\n>>\n>>\n>> I would like to propose an enhancement to git init that allows users to specify a\n>language or framework when initializing a repository, automatically applying an\n>appropriate .gitignore template.\n>>\n>> Proposal\n>>\n>> Introduce a flag to git init that enables users to initialize a repository with a\n>predefined .gitignore based on the project's language or framework. For example:\n>>\n>> git init --golang\n>> git init --python\n>> git init --node\n>>\n>> This would generate a .gitignore file using well-established templates, such as\n>those from Toptal's Gitignore Generator\n>https://www.toptal.com/developers/gitignore/ or GitHub's official .gitignore\n>repository.\n>\n>I think this is an interesting idea, but unfortunately, I think it's going to be practically\n>difficult to implement.  You've mentioned three very common languages, but there\n>are a lot of programming languages and even more compiler environments, and it\n>wouldn't be practical for us to try to support them all.\n>\n>For instance, I use Neovim, and the version I'm using ships with 693 different syntax\n>files, which means that there's about 693 different programming languages\n>supported.  I was recently exposed at work to some languages that I'd never heard\n>about before and which are not supported by Neovim, and presumably those users\n>would also want similar functionality.\n>\n>That is compounded by the fact that there are a lot of OS- and environment-specific\n>configuration.  As an example, a C project on macOS might want to ignore XCode-\n>related files, but for a project that's only on Linux, that wouldn't be necessary.\n>Similarly, that C project might create shared libraries that should be ignored, but\n>those might end up with any of `.so`, `.sl`, `.dylib`, or `.dll` extensions.\n>\n>You mentioned some possible sources for this configuration, but we try not to\n>prioritize specific outside projects.  So just because GitHub is widely used and some\n>GitHub employees contribute to Git doesn't mean we give it special precedence or\n>privileges, and we wouldn't want to prioritize their specific collection (or any other),\n>nor would be want `git init` to attempt to make a network connection.  We also\n>don't want to maintain this collection ourselves, since it's very project specific.\n>\n>What Git _does_ provide is a way to create a template of objects that should be in\n>the `.git` directory using the `--template` option.  It's possible to create a template\n>that contains an initial commit with a `.gitignore` file.  I personally would not\n>recommend this approach, since it will not work gracefully with alternate ref\n>formats or hash algorithms, but it is an option for people who want to use it.  This\n>was in common use for setting up the default branch name before `git init` added\n>the `-b` option and it's related config, so it is well tested.\n\nOne way to deal with this is to add language-specific descriptors. What I did in my\nown front end is to provide a set of regex patterns that define the relevant portions\nof the languages and extensions. This allows my end-users to add their own languages\nand leave me out of it completely. It might be workable if we have a quantified\nextensible language structure for this. Otherwise, this might be DOA.\n\n--Randall\n\n"},{"id":"513621","messageId":"xmqq1pvbks3i.fsf@gitster.g","threadId":"63056","inReplyTo":"Z8jTjt1CQ7hp8KSP@tapette.crustytoothpaste.net","subject":"Re: Suggestion: Enhance git init with Language-Specific Templates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-05T22:52:49Z","receivedAt":"2025-03-05T22:52:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> What Git _does_ provide is a way to create a template of objects that\n> should be in the `.git` directory using the `--template` option.  It's\n> possible to create a template that contains an initial commit with a\n> `.gitignore` file.  I personally would not recommend this approach,\n> since it will not work gracefully with alternate ref formats or hash\n> algorithms, but it is an option for people who want to use it.  This was\n> in common use for setting up the default branch name before `git init`\n> added the `-b` option and it's related config, so it is well tested.\n\nI wouldn't have thrown objects in the --template directory, and I\nwouldn't count on things outside what the mechanism was invented for\n(namely, .git/hooks and possibly .git/info/ files) would forever be\ncopied in newer versions of Git, but certainly \"git init --template\"\nmechanism sounds like a good escape hatch than mucking with Git code\nbase to teach it myriad of languages and their dialects.\n\nThanks.\n"},{"id":"513624","messageId":"CABEd3j-36C_LUOetg0qLofrby9M1Hixkh4o7sQkkyyWuTqHQvQ@mail.gmail.com","threadId":"63056","inReplyTo":"xmqq1pvbks3i.fsf@gitster.g","subject":"Re: Suggestion: Enhance git init with Language-Specific Templates","fromName":"Oleg Taranenko","fromEmail":"olegtaranenko@gmail.com","sentAt":"2025-03-05T23:53:30Z","receivedAt":"2025-03-05T23:53:44Z","isPatch":false,"sender":{"key":"olegtaranenko@gmail.com","avatar":"https://gravatar.com/avatar/016106c4926412cef4141b2d7cea4378aef44db0ca56c9462a5f4a71c7a80955?d=mp&s=160"},"body":"On Wed, 5 Mar 2025 at 23:53, Junio C Hamano <gitster@pobox.com> wrote:\n\n> I wouldn't have thrown objects in the --template directory, and I\n> wouldn't count on things outside what the mechanism was invented for\n> (namely, .git/hooks and possibly .git/info/ files) would forever be\n> copied in newer versions of Git, but certainly \"git init --template\"\n> mechanism sounds like a good escape hatch than mucking with Git code\n> base to teach it myriad of languages and their dialects.\n\nIt sounds like creating a copy of the .gitignore structure requires\nthe user to learn bash script syntax. :-D I'd like to suggest adding\none more option to the init --template <template/dir>\n--only-gitignores. It will not deal with all the complicated mechanics\nbehind hooks/etc, and will only look at the template folder structure\nand copy **/.gitignore into the newly created worktree. In case of\nexisting .gitignore files, just put warnings and do not override\nthose.\n\n\n--Oleg\n"},{"id":"513625","messageId":"xmqqsenrjaka.fsf@gitster.g","threadId":"63056","inReplyTo":"CABEd3j-36C_LUOetg0qLofrby9M1Hixkh4o7sQkkyyWuTqHQvQ@mail.gmail.com","subject":"Re: Suggestion: Enhance git init with Language-Specific Templates","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-03-05T23:56:53Z","receivedAt":"2025-03-05T23:56:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Oleg Taranenko <olegtaranenko@gmail.com> writes:\n\n> On Wed, 5 Mar 2025 at 23:53, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> I wouldn't have thrown objects in the --template directory, and I\n>> wouldn't count on things outside what the mechanism was invented for\n>> (namely, .git/hooks and possibly .git/info/ files) would forever be\n>> copied in newer versions of Git, but certainly \"git init --template\"\n>> mechanism sounds like a good escape hatch than mucking with Git code\n>> base to teach it myriad of languages and their dialects.\n>\n> It sounds like creating a copy of the .gitignore structure requires\n> the user to learn bash script syntax. :-D I'd like to suggest adding\n> one more option to the init --template <template/dir>\n> --only-gitignores. It will not deal with all the complicated mechanics\n> behind hooks/etc, and will only look at the template folder structure\n> and copy **/.gitignore into the newly created worktree. In case of\n> existing .gitignore files, just put warnings and do not override\n> those.\n\nI was referring to .git/info because of the .git/info/excludes file.\n"},{"id":"513626","messageId":"CABEd3j9WqykwmNF_z-eeKcdFRAjYpKkFnciVBwpYLnteS62yZA@mail.gmail.com","threadId":"63056","inReplyTo":"xmqqsenrjaka.fsf@gitster.g","subject":"Re: Suggestion: Enhance git init with Language-Specific Templates","fromName":"Oleg Taranenko","fromEmail":"olegtaranenko@gmail.com","sentAt":"2025-03-06T00:04:21Z","receivedAt":"2025-03-06T00:04:38Z","isPatch":false,"sender":{"key":"olegtaranenko@gmail.com","avatar":"https://gravatar.com/avatar/016106c4926412cef4141b2d7cea4378aef44db0ca56c9462a5f4a71c7a80955?d=mp&s=160"},"body":"On Thu, 6 Mar 2025 at 00:56, Junio C Hamano <gitster@pobox.com> wrote:\n\n> I was referring to .git/info because of the .git/info/excludes file.\n\n.git/info/excludes is a great feature, but it often needs to persist\nignored structure, for example, in case of creating a zillion small\nprojects/repos for the learning process.\n"}]}