{"thread":{"id":"55059","subject":"git stash push --patch offers skip-worktree hunks","startedAt":"2021-01-27T08:23:18Z","lastAt":"2021-01-27T13:25:57Z","messageCount":2,"participants":["Daniel Lublin","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"415408","messageId":"rur7en$16bk$1@ciao.gmane.io","threadId":"55059","inReplyTo":null,"subject":"git stash push --patch offers skip-worktree hunks","fromName":"Daniel Lublin","fromEmail":"daniel@lublin.se","sentAt":null,"receivedAt":"2021-01-27T08:23:18Z","isPatch":false,"sender":{"key":"daniel@lublin.se","avatar":null},"body":"Hi,\n\nI'm using this to hide some locally modified files from accidental commit:\n\n  git update-index --skip-worktree ...\n\nDoing `git stash push` does not result in the above modifications being\nstashed. But, doing `git stash push --patch` asks me about hunks in the\nfiles which were flagged to skip-worktree. Instinctively, this feels wrong.\nThe docs also say:\n\n  Interactively select hunks from the diff between HEAD and the working tree\n  to be stashed.\n\nWhat do you think?\n\nregards,\n\n-- \nDaniel\nlublin.se\n\n"},{"id":"415416","messageId":"YBFo8xJu57fC1PO/@camp.crustytoothpaste.net","threadId":"55059","inReplyTo":"rur7en$16bk$1@ciao.gmane.io","subject":"Re: git stash push --patch offers skip-worktree hunks","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-01-27T13:21:55Z","receivedAt":"2021-01-27T13:25:57Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-01-27 at 08:15:19, Daniel Lublin wrote:\n> Hi,\n> \n> I'm using this to hide some locally modified files from accidental commit:\n> \n>   git update-index --skip-worktree ...\n\nThis isn't the intended purpose of this functionality, and as you've\nseen it doesn't work properly for that case.  From gitfaq(7):\n\nHow do I ignore changes to a tracked file?\n\n  Git doesn't provide a way to do this.  The reason is that if Git needs\n  to overwrite this file, such as during a checkout, it doesn't know\n  whether the changes to the file are precious and should be kept, or\n  whether they are irrelevant and can safely be destroyed.  Therefore,\n  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 template\n  or set of defaults which can then be copied alongside and modified as\n  appropriate.  This second, modified file is usually ignored to prevent\n  accidentally committing it.\n\nThere is a lot of misinformation on Stack Overflow, which is why I wrote\nthat FAQ entry.  Unfortunately, I can only downvote a wrong answer once.\n\nThe skip-worktree bit is designed to prevent the file from being checked\nout as part of sparse checkout.\n\n> Doing `git stash push` does not result in the above modifications being\n> stashed. But, doing `git stash push --patch` asks me about hunks in the\n> files which were flagged to skip-worktree. Instinctively, this feels wrong.\n> The docs also say:\n> \n>   Interactively select hunks from the diff between HEAD and the working tree\n>   to be stashed.\n> \n> What do you think?\n\nIt looks like there is a test for the case without --push in t3903, and\nit looks like Dscho (CC'd) last touched it, so maybe he's familiar with\nwhat might be going on here.\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"}]}