mtime is not restored after --autostash

From: Jos van den Oever <hidden>
Date: 2026-08-13 18:10:23

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

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help