git-utimes
Modify file access and modification timestamps
TLDR
Change all files modification time to their last commit date
Change files modification time that are newer than their last commit date, preserving original modification time of files that were committed from the local repository
SYNOPSIS
git-utimes <path>
PARAMETERS
<path>
Path to the file or directory whose atime and mtime to reset to current second-precision values
DESCRIPTION
git-utimes is an internal helper program from the Git source code's test suite, located at t/helper/git-utimes.c. It is not a publicly installed command but a small executable used during Git's automated testing to precisely control file timestamps.
The program takes a single path argument, statistically retrieves the file's current access time (atime) and modification time (mtime), and then uses utimensat(2) to reset them. Importantly, it truncates nanosecond precision by setting tv_nsec to 0 while preserving the second-level timestamps from stat(2). This ensures consistent, whole-second timestamps in test environments, avoiding flakiness due to sub-second variations.
Usage is typically via ./t/helper/git-utimes somefile within Git's t/ test directory. It exits with 0 on success or dies with an error message on failure (e.g., stat or utimensat errors). Not meant for production or general filesystem manipulation.
CAVEATS
Internal Git test tool only; not installed or documented for users.
Requires executable permissions on the binary.
Truncates nanoseconds, altering precise timestamps.
IMPLEMENTATION
Reads path via argv[1], calls stat(), constructs timespec array with tv_nsec=0, invokes utimensat(AT_FDCWD, path, ts, 0).
BUILD
Compiled as part of make test in Git source; run from git --exec-path or t/helper/.
HISTORY
Part of Git's test suite helpers since around Git 2.20 (2018), used in tests like t7003-filter-branch.sh to normalize timestamps for reproducible outcomes.
SEE ALSO
touch(1), utimes(2), utimensat(2), git-update-index(1)


