GIT-RESTORE-MTIME(1)
π GIT-RESTORE-MTIME(1) π
okay bestie so this is from the General Commands Manual and it's literally one of the most useful little gremlins in the git-tools family. let's get into it π¦
β¨ NAME β¨
git-restore-mtime β restore the original modification time of files based on the date of the most recent commit that modified them πΈ
β¨ SYNOPSIS β¨
git-restore-mtime [-h] [--quiet|--verbose]
[-C DIRECTORY] [--work-tree WORKDIR] [--git-dir GITDIR]
[--force] [--merge] [--first-parent] [--skip-missing]
[--no-directories] [--test] [--commit-time] [--oldest-time]
[--skip-older-than SECONDS] [--unique-times]
[--version]
[PATHSPEC [PATHSPEC...]]
β¨ DESCRIPTION β¨
so what this does: it changes the modification time (mtime) of files in the work tree, based on the date of the most recent commit that touched each file. it's basically an attempt to restore the original mtime, which is so useful when you're generating release tarballs π¦β¨
it ignores untracked files, and uncommitted deletions, additions and renames. and by default? modifications too π
β¨ OPTIONS β¨
π Positional arguments
PATHSPECβ only modify paths matching PATHSPEC, relative to the current directory. by default it updates everything except untracked files and submodules π«Ά
π Optional arguments
-h,--helpβ show the help message and exit, iconic behaviour honestly--quiet,-qβ suppress informative messages and summary statistics π€«--verbose,-vβ print additional information for each processed file. specify it twice to crank the verbosity up even further π₯-C DIRECTORY,--cwd DIRECTORYβ run as ifrestore-mtimewas started in directory DIRECTORY. this affects how the--work-tree,--git-dirand PATHSPEC arguments are handled. peepgit(1)for more info π--git-dir GITDIRβ path to the git repository. by default it's auto-discovered by searching the current directory and its parents for a.git/subdirectory π--work-tree WORKDIRβ path to the work tree root. by default it's the parent of GITDIR if that was automatically discovered, or the current directory if GITDIR is set ποΈ--force,-fβ force updating files that have uncommitted modifications. but bestie, note this: untracked files and uncommitted deletions, renames and additions are always ignored, no exceptions π€--merge,-mβ include merge commits. this leads to more recent times and more files per commit, which means they all get the same time β which may or may not be what you want, iykyk π€·ββοΈ including merge commits may also lead to fewer commits being evaluated since files get found sooner, which can improve performance, sometimes substantially π but as merge commits are usually huge, processing them may also take longer π by default, merge commits are only used for files that are missing from regular commits.--first-parentβ consider only the first parent, aka the "main branch", when evaluating merge commits. only effective when merge commits are actually processed β either when--mergeis used, or when finding missing files after the first regular log search. see--skip-missingπ--skip-missing,-sβ do not try to find missing files. if merge commits weren't evaluated with--mergeand some files weren't found in regular commits, by defaultrestore-mtimesearches for those files again in the merge commits. this option disables that retry, so files found only in merge commits will not have their timestamp updated π--no-directories,-Dβ do not update directory timestamps. by default it uses the time of its most recently created, renamed or deleted file. note that just modifying a file will NOT update its directory time π ββοΈ--test,-tβ test run: don't actually update any file timestamp. a lil dress rehearsal π--commit-time,-cβ use commit time instead of author time β°--oldest-time,-oβ update times based on the oldest commit instead of the most recent one of a file. this reverses the order in which the git log is processed, to emulate a file "creation" date. note this will be inaccurate for files deleted and re-created at later dates π°οΈ--skip-older-than SECONDSβ ignore files that are currently older than SECONDS. useful in workflows that assume such files already have a correct timestamp, since it may improve performance by processing fewer files β‘--skip-older-than-commit,-Nβ ignore files older than the timestamp it would be updated to. such files may be considered "original", likely in the author's repository π§--unique-timesβ set the microseconds to a unique value per commit. this lets you tell apart changes that would otherwise have identical timestamps, since git's time accuracy is in seconds π¬--version,-Vβ show the program's version number and exit π
β¨ KNOWN ISSUES β¨
bestie these are the real ones, read them fr fr π
- Renames are poorly handled: it always changes the timestamps of files, even if no content was modified.
- Directory timestamps are also limited to being modified only when files are added (created) or deleted in them.
- In very large repositories, after running restore-mtime to modify the timestamp of several files, further git operations may emit the error:
fatal: mmap failed: Cannot allocate memory.
This is harmless, and can be fixed by running git-status(1) β
β¨ SEE ALSO β¨
git(1), git-log(1), git-ls-files(1), git-status(1)
https://github.com/MestreLion/git-tools π
β¨ AUTHOR β¨
Rodrigo Silva (MestreLion) linux@rodrigosilva.com π
and that's the whole page bestie, you ate that π«Ά this beauty is dated 2022-07-27 and it lives under the GIT-RESTORE-MTIME(1) banner, mwah π β¨
π¦ where this page comes from
- debian bookworm: git-restore-mtime 2022.12-1 Β· GPL-3.0-or-later
- debian trixie: git-restore-mtime 2022.12-1 Β· GPL-3.0-or-later
- epel 10: git-tools 2025.08-1.el10_2 Β· GPL-3.0-or-later
- epel 9: git-tools 2025.08-1.el9 Β· GPL-3.0-or-later
- fedora 43: git-tools 2025.08-1.fc43 Β· GPL-3.0-or-later
- fedora 44: git-tools 2025.08-2.fc44 Β· GPL-3.0-or-later
- nixos 26.05: git-tools 2025.08
- nixpkgs unstable: git-tools 2025.08
- ubuntu noble: git-restore-mtime 2022.12-1 Β· GPL-3.0-or-later
- ubuntu questing: git-restore-mtime 2022.12-1
- ubuntu resolute: git-restore-mtime 2022.12-1build1 Β· GPL-3.0-or-later
- ubuntu stonking: git-restore-mtime 2022.12-1build1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms