You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查看Git其他分支或提交中指定文件的mtime(最后修改时间)

使用git ls-files --debug或stat命令,可查看*当前分支(严格为当前提交)*中文件的mtime(最后修改时间)。

$ 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

那么是否有方法可以查看*其他分支(其他提交)*中同一文件的该信息?


临时解决方案

目前有两种可行方案,但都算不上优雅的解法:

  • 先执行git checkout <commit>切换到对应提交,再运行git ls-files --debug <file>查看。
  • 先执行git blame <commit> <file>,其输出包含多个时间戳,可借助cut、sort、sed等工具解析后提取最新时间戳。

内容的提问来源于stack exchange,提问作者ynn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 10:36:02