Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git ls-files with date?

Tags:

git

On GitHub you have this nice feature on each folder page, it lists the file name along with the age of the last commit to that file. This is similar to the ls -l command.

Is there a way to mimic this behavior from the command line? Something like

git ls-files -l

Based on sjas answer this works for me

ls | while read aa
do
  git log -1 --format="%ai  $aa" "$aa"
done
like image 337
Zombo Avatar asked Jul 25 '12 11:07

Zombo


1 Answers

$ for a in $(ls); do git log --pretty=format:"%h%x09%an%x09%ad%x09$a" -1 -- "$a"; done
e76b    sjas    Tue Jul 24 21:55:20 2012 +0200  bashscripts/
68af    sjas    Wed Jul 25 13:49:26 2012 +0200  links
83c9    sjas    Tue Jul 24 15:21:09 2012 +0200  rndm/
aedf    sjas    Tue Jul 24 15:14:12 2012 +0200  temp/
a643    sjas    Tue Jul 24 21:48:19 2012 +0200  tips/
f71d    sjas    Tue Jul 24 19:26:20 2012 +0200  todo

Taken from https://stackoverflow.com/a/469238/805284

In case this looks strange:
My SHA1's are abbreviated to only 4 numbers via core.abbrev=4 in my .gitconfig.

But maybe you have use for this here:

$ for a in $(ls); do git log --pretty=format:"%h%x09$a%x09%s" -1 -- "$a"; done
e76b    bashscripts/   added pushd/popd/dirs shortcuts!!!
68af    links          fastcommit
83c9    rndm/          further cleanup
aedf    temp/          tempcommit
a643    tips/          added disk usage script and pushd/popd annotation
f71d    todo           fastcommit
like image 104
sjas Avatar answered Sep 20 '22 12:09

sjas