{"thread":{"id":"63920","subject":"`git stash --include-untracked` touches .pack files","startedAt":"2025-08-07T02:27:07Z","lastAt":"2025-08-11T09:10:32Z","messageCount":2,"participants":["johnkw","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"523694","messageId":"2ea19b6b-716b-4736-8dd3-8831056c39f9@gmail.com","threadId":"63920","inReplyTo":null,"subject":"`git stash --include-untracked` touches .pack files","fromName":"johnkw","fromEmail":"johnkw@gmail.com","sentAt":"2025-08-07T02:27:05Z","receivedAt":"2025-08-07T02:27:07Z","isPatch":false,"sender":{"key":"johnkw@gmail.com","avatar":null},"body":"`git stash --include-untracked` causes the timestamp to be touched for \nsome .pack files.  It's not always all .pack files, although I don't see \na pattern regarding how some survive the operation with the timestamp \nintact.  For a given repo it seems consistent though on the .pack files \nimpacted by the issue.\n\nThis breaks backup systems such as rsync, causing pointless churn.\n\nThe issue occurs with or without \".keep\" files for the \".pack\" files in \nquestion.\n\n`git stash` without `--include-untracked` does not have this issue.\n\nThe issue occurs with no untracked files actually even in the repo for \n`--include-untracked` to take action on.\n"},{"id":"523917","messageId":"aJmzgfucZIJf_iQA@pks.im","threadId":"63920","inReplyTo":"2ea19b6b-716b-4736-8dd3-8831056c39f9@gmail.com","subject":"Re: `git stash --include-untracked` touches .pack files","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-08-11T09:10:25Z","receivedAt":"2025-08-11T09:10:32Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Aug 06, 2025 at 09:27:05PM -0500, johnkw wrote:\n> `git stash --include-untracked` causes the timestamp to be touched for some\n> .pack files.  It's not always all .pack files, although I don't see a\n> pattern regarding how some survive the operation with the timestamp intact. \n> For a given repo it seems consistent though on the .pack files impacted by\n> the issue.\n> \n> This breaks backup systems such as rsync, causing pointless churn.\n> \n> The issue occurs with or without \".keep\" files for the \".pack\" files in\n> question.\n> \n> `git stash` without `--include-untracked` does not have this issue.\n> \n> The issue occurs with no untracked files actually even in the repo for\n> `--include-untracked` to take action on.\n\nWhat you probably see here is Git freshening its objects: when Git is\nasked to write objects into the object database that it already knows\nabout it will freshen the access time of each such object. If the object\nis stored in a packfile, then the whole packfile is getting freshened.\n\nThis is overall an expected outcome, and Git relies on those freshened\naccess times to do garbage collection. So this isn't something that we\ncan change. One _could_ have a look at `save_untracked_files()` and\nteach it to skip writing objects in case there is nothing to be done.\nBut honestly, I doubt that this would really solve the underlying issue\nfor you, as any other command that writes objects might also cause Git\nto freshen the packfile.\n\nPatrick\n"}]}