{"thread":{"id":"45089","subject":"Automatically Add .gitignore Files","startedAt":"2017-02-08T22:14:11Z","lastAt":"2017-02-09T17:26:56Z","messageCount":5,"participants":["Thangalin","Junio C Hamano","Stephan Beyer","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"311109","messageId":"CAANrE7rmUZcJkw+thMczv3D=7sqcUHBsorzvEZgYg=6AEfrU=w@mail.gmail.com","threadId":"45089","inReplyTo":null,"subject":"Automatically Add .gitignore Files","fromName":"Thangalin","fromEmail":"thangalin@gmail.com","sentAt":"2017-02-08T19:05:28Z","receivedAt":"2017-02-08T22:14:11Z","isPatch":false,"sender":{"key":"thangalin@gmail.com","avatar":null},"body":"I frequently forget to add .gitignore files when creating new .gitignore files.\n\nI'd like to request a command-line option to always add .gitignore\nfiles (or, more generally, always add files that match a given file\nspecification).\n\nReplicate\n\n0. git init ...\n1. echo \"*.bak\" >> .gitignore\n2. touch file.txt\n3. git add file.txt\n4. git commit -a -m \"...\"\n5. git push origin master\n\nExpected Results\n\nThe .gitignore file is also added to the repository. (This is probably\nthe 80% use case.)\n\nActual Results\n\nThe .gitignore file is not added to the repository.\n\nAdditional Details\n\nAt step 4, there should be a prompt, warning, or (preferably) either a\ncommand-line or configuration option to add the .gitignore file prior\nto commit, automatically. Such as:\n\ngit commit --include-all-gitignore-files -a -m \"...\"\n\nOr:\n\necho \"**/.gitignore\" >> .git/config/add-before-commit\n"},{"id":"311122","messageId":"xmqqmvdwtfq8.fsf@gitster.mtv.corp.google.com","threadId":"45089","inReplyTo":"CAANrE7rmUZcJkw+thMczv3D=7sqcUHBsorzvEZgYg=6AEfrU=w@mail.gmail.com","subject":"Re: Automatically Add .gitignore Files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-02-08T23:39:11Z","receivedAt":"2017-02-08T23:47:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thangalin <thangalin@gmail.com> writes:\n\n> I frequently forget to add .gitignore files when creating new .gitignore files.\n>\n> I'd like to request a command-line option to always add .gitignore\n> files (or, more generally, always add files that match a given file\n> specification).\n\nThat is essentially what \"Untracked files\" listing in the editor\nbuffer given to you when you type \"git commit\" is about.  By not\nsaying you ignore .gitattributes, .gitignore, .gitmodules, etc., you\nare reminded if you forgot to add them.  \"git status\" does the same,\nand perhaps you want to make it a habit to run it before committing.\n\nI am tempted to say that there should be a way to somehow forbid use\nof the \"-m\" option to \"git commit\" by default, until the user gains\nmore familiarity with use of Git.  That way, they will learn to pay\nmore attention to the \"Untracked\" and \"Changes not staged\" sections\n;-)\n"},{"id":"311125","messageId":"64116970-0907-2e95-e49d-068e1a25ffa6@gmx.net","threadId":"45089","inReplyTo":"xmqqmvdwtfq8.fsf@gitster.mtv.corp.google.com","subject":"Re: Automatically Add .gitignore Files","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2017-02-09T00:01:58Z","receivedAt":"2017-02-09T00:02:22Z","isPatch":false,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"> I am tempted to say that there should be a way to somehow forbid use\n> of the \"-m\" option to \"git commit\" by default, until the user gains\n> more familiarity with use of Git.\n\nSince I am using git, I am tempted to say that \"git commit -m\" should be\nabolished. If I tell somebody how to use git, I never mention \"git\ncommit -m\". Unluckily they find it out themselves... ;D\n\nThe typical observations I have when people use \"git commit -m\":\n\n * The commit messages are either too long (in one line!) or\n   too meaningless.\n\n * People don't check what they added and commit wrong stuff.\n\n * People make fast temporary commits with \"asdafsd\" commit messages.\n   Then they get distracted for some time and work on another branch.\n   When they turn back to the old branch they don't know what \"asdafsd\"\n   was...\n\nThanks to git rebase -i and/or git commit --amend, it is all not too bad\nafter all ;D\n\nBest\n  Stephan\n"},{"id":"311156","messageId":"CACsJy8DoXCNzryQusEcXtOgeU2ZH1FMGEK32z5b=PGkfvJ0BTg@mail.gmail.com","threadId":"45089","inReplyTo":"CAANrE7rmUZcJkw+thMczv3D=7sqcUHBsorzvEZgYg=6AEfrU=w@mail.gmail.com","subject":"Re: Automatically Add .gitignore Files","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2017-02-09T10:03:00Z","receivedAt":"2017-02-09T10:04:30Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Feb 9, 2017 at 2:05 AM, Thangalin <thangalin@gmail.com> wrote:\n> I frequently forget to add .gitignore files when creating new .gitignore files.\n>\n> I'd like to request a command-line option to always add .gitignore\n> files (or, more generally, always add files that match a given file\n> specification).\n>\n> Replicate\n>\n> 0. git init ...\n> 1. echo \"*.bak\" >> .gitignore\n> 2. touch file.txt\n> 3. git add file.txt\n> 4. git commit -a -m \"...\"\n> 5. git push origin master\n>\n> Expected Results\n>\n> The .gitignore file is also added to the repository. (This is probably\n> the 80% use case.)\n\nThis is a general problem to new files, not .gitignore alone. Can we\naccomplish something with some hook? At the least I think we should be\nable to detect that .gitignore is not detected and abort, prompting\nthe user to add it. It's easier to customize too, and we don't have to\ncook \".gitignore\" in the code.\n\nI'm not sure if we tell the hook \"this is with -m option\" though..\n-- \nDuy\n"},{"id":"311191","messageId":"CAANrE7rXUCjBkgmGjiXMMJuTh+FXmw-bLKqonQ4BQP0_=p5m-Q@mail.gmail.com","threadId":"45089","inReplyTo":"CACsJy8DoXCNzryQusEcXtOgeU2ZH1FMGEK32z5b=PGkfvJ0BTg@mail.gmail.com","subject":"Re: Automatically Add .gitignore Files","fromName":"Thangalin","fromEmail":"thangalin@gmail.com","sentAt":"2017-02-09T17:25:29Z","receivedAt":"2017-02-09T17:26:56Z","isPatch":false,"sender":{"key":"thangalin@gmail.com","avatar":null},"body":"Hi Duy,\n\n> This is a general problem to new files, not .gitignore alone. Can we\n\nThe difference, to me, is that a \".gitignore\" file is not part of what\nI'm developing. It's an artifact for git configuration. While a\n.gitignore file is not always pushed to the repository, I imagine that\nin most situations, it is.\n\nWhereas when a \"new\" file is created, there are plenty of situations\nwhere it shouldn't be added and thus a warning would be superfluous,\nor an automatic add would be undesirable.\n\nTo solve the problem, generally, for new files while giving the user\nthe ability to specify exactly what \"new\" files should be\nautomatically added to the repository, something like the following\nwould work:\n\necho \"**/.gitignore\" >> .git/config/add-before-commit\n\n> and perhaps you want to make it a habit to run it before committing.\n\nRight, because software shouldn't automate repetitive tasks and humans\nare never prone to forget? ;-)\n"}]}