neubert
neubert

Reputation: 16792

finding out the last modified time of all modified files in git

If I do git status I see a bunch of changed files and a few new ones as well. I'd like to be able to see the last modified time of each of these files (and from there see which one is the oldest / newest) but it is not clear to me how to do that. Any ideas?

Upvotes: 1

Views: 925

Answers (2)

Leandro Papasidero
Leandro Papasidero

Reputation: 3738

Committed File Information

git ls-tree -r --name-only HEAD | while read filename; do
  echo "$(git log -1 --format="%ad" -- $filename) $filename"
done

Modified Files without commit Information

git status --porcelain | awk {'print $2'} | while read filename; do 
  echo -n $filename ' ' ; stat $filename | grep Modify;
done

Upvotes: 2

wallyk
wallyk

Reputation: 57774

There is surely a better way, but a method which works is

$ git ls-files --debug
yaml_parse.py
  ctime: 1434026542:225611371
  mtime: 1433442706:0
  dev: 34   ino: 17436117
  uid: 33156    gid: 4720
  size: 5065    flags: 0

$ cvttime 1433442706
1433442706 = 2015-06-04 Thu 18:31:46 +0000 (UTC)

Upvotes: 1

Related Questions