Using git ls-files --debug
or stat
command, you can see the mtime (last modified time) of a file in a current branch (strictly in a current commit).
$ git ls-files --debug main.py main.py ctime: 1626910912:885869194 mtime: 1626910912:869124612 dev: 16777234 ino: 8580291 uid: 501 gid: 20 size: 4832 flags: 0
$ stat main.py File: main.py Size: 4832 Blocks: 16 IO Block: 4096 regular file Device: 1000012h/16777234d Inode: 8580291 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 501/ user) Gid: ( 20/ staff) Access: 2021-07-22 09:08:43.090154548 +0900 Modify: 2021-07-22 08:41:52.869124612 +0900 Change: 2021-07-22 08:41:52.885869194 +0900 Birth: 2021-07-22 08:41:52.868783790 +0900
Then is there any way to see this information for the same file in another branch (another commit)?
Workarounds
Currently I have two workarounds, both of which I don’t think are beautiful solutions.
First
git checkout <commit>
and thengit ls-files --debug <file>
.First
git blame <commit> <file>
. The output includes many timestamps. Parsing them, pick the latest timestamp (usingcut
,sort
,sed
, etc.).
Advertisement
Answer
You can get modification time in another branch with :
git log -1 --pretty="format:%ci" branch-name -- file-name