git status - list last modified date
Note: I needed to get the modified files sorted by date, so I modified the echo:
git status -s | while read mode file; \
do echo $mode $(stat -c %y $file) $file; \
done|sort -k1,4
One line:
git status -s | while read mode file; do echo $mode $(stat -c %y $file) $file; done|sort -k1,4
By echoing first the date (stat
), and then the file, I was able to sort from oldest to newest modification.
Sam Hasler adds in the comments:
To preserve spaces in mode:
IFS=''; git status -s | while read -n2 mode; read -n1; read file; do echo $mode $(stat -c %y "$file") $file; done|sort
That is:
IFS=''; git status -s | while read -n2 mode; read -n1; read file; \
do echo $mode $(stat -c %y "$file") $file; \
done|sort
Not directly but you can use a pipe:
Note: original answer updated based on comments
Linux:
git status -s | while read mode file; do echo $mode $file $(stat -c %y $file); done
Windows:
git status -s | while read mode file; do echo $mode $(date --reference=$file +"%Y-%m-%d %H:%M:%S") $file; done
OSX (source):
git status -s | while read mode file; do echo $mode $(stat -f "%Sm" $file) $file; done|sort