{"thread":{"id":"61213","subject":"Ignore specific changes but not the entire file","startedAt":"2024-03-28T07:46:20Z","lastAt":"2024-03-28T22:20:40Z","messageCount":2,"participants":["Mohammad Al Zouabi","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"491724","messageId":"CAAQqY-NKvWMLo_Bcby5-QYPOj-jbWeVA3zGL=_sq2p2bGZQBEA@mail.gmail.com","threadId":"61213","inReplyTo":null,"subject":"Ignore specific changes but not the entire file","fromName":"Mohammad Al Zouabi","fromEmail":"mb.alzouabi@gmail.com","sentAt":"2024-03-28T07:46:08Z","receivedAt":"2024-03-28T07:46:20Z","isPatch":false,"sender":{"key":"mb.alzouabi@gmail.com","avatar":null},"body":"The problem with:\n\n```sh\ngit update-index [--skip-worktree|--assume-unchanged]\n```\n\nIs that it ignores the entire file.\n\nIs there a plan to support something that remembers what was exactly\nignored, and if there are changes to it, either un-ignore the file, or\ndisplay the hunks that were changed?\n\nSomething like committing the change but not actually committing it.\n"},{"id":"491792","messageId":"ZgXtNknnAIRfzrXt@tapette.crustytoothpaste.net","threadId":"61213","inReplyTo":"CAAQqY-NKvWMLo_Bcby5-QYPOj-jbWeVA3zGL=_sq2p2bGZQBEA@mail.gmail.com","subject":"Re: Ignore specific changes but not the entire file","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-03-28T22:20:38Z","receivedAt":"2024-03-28T22:20:40Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-03-28 at 07:46:08, Mohammad Al Zouabi wrote:\n> The problem with:\n> \n> ```sh\n> git update-index [--skip-worktree|--assume-unchanged]\n> ```\n> \n> Is that it ignores the entire file.\n> \n> Is there a plan to support something that remembers what was exactly\n> ignored, and if there are changes to it, either un-ignore the file, or\n> display the hunks that were changed?\n\nNo, because the Git FAQ is clear that Git doesn't support ignoring\ntracked files at all[0]:\n\n    Git doesn’t provide a way to do this. The reason is that if Git\n    needs to overwrite this file, such as during a checkout, it doesn’t\n    know whether the changes to the file are precious and should be\n    kept, or whether they are irrelevant and can safely be destroyed.\n    Therefore, it has to take the safe route and always preserve them.\n\n    It’s tempting to try to use certain features of git update-index,\n    namely the assume-unchanged and skip-worktree bits, but these don’t\n    work properly for this purpose and shouldn’t be used this way.\n\n    If your goal is to modify a configuration file, it can often be\n    helpful to have a file checked into the repository which is a\n    template or set of defaults which can then be copied alongside and\n    modified as appropriate. This second, modified file is usually\n    ignored to prevent accidentally committing it.\n\nSo the functionality that you're using is not intended to be used that\nway and in fact is broken for that purpose in a variety of subtle ways\nthat you'll notice if you keep using it.\n\nIf you need to generate files from a variety of sources, some of which\nshould be tracked and some which should not, you can do something like\ncreate a directory foo.cfg.d, and use a script to include files from\nthat directory to generate your config (which would be in an ignored\nfile).  You can have some of those files be tracked (and hence\ndiffable), and others be ignored, and then the script can generate the\nproper data.  This same approach is used on Unix systems for generating\nconfiguration files and is well known, so it shouldn't be too difficult\nto configure in most cases.\n\n[0] https://git-scm.com/docs/gitfaq#ignore-tracked-files\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"}]}