git/list[1] front-page[2] threads[3] people[4] search[5] about
 

mtime is not restored after --autostash

From
JOJos van den Oever <jos@vandenoever.info>
Date
Aug 13, 2026, 18:02 UTC
Message-ID
<40429f46-ff82-4149-8204-2d4ab1925117@vandenoever.info>
Dear git developers,

When git pull, merge, and rebase are used with --autostash and modify the current working directory, the mtime of files that are restored (stash apply) are set to the current time, even when the files have not changed.

In my understanding, git usually does nothing to the mtime of files so their mtime is set to the current time when they are written instead of e.g. the mtime of the commit date that is checked out. This ensures that build systems will run actions for which the changed file is an input.

When using --autostash there is the opportunity to restore the mtime that the dirty file had before the git command. This can save a lot of work for the build system.

There is another use case where restoring the mtime is useful: using git for unattended syncing of files. A system that checks in files automatically, after a cooling off period, could use the mtime as the author date of the commit. If --autostash changes the mtime, that date is wrong. Such a system could work around this by keeping track of the mtimes of dirty and new files and restoring them itself instead of relying on --autostash to do so.

Best regards, Jos van den Oever

Message 1 of 1 in “mtime is not restored after --autostash”
  1. Jos van den OeverAug 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.