在GitHub上,每个文件夹页面上都有此功能,它列出了文件名以及对该文件的最后提交时间。这类似于ls -l命令。

有没有办法从命令行模仿这种行为?就像是

git ls-files -l

基于sjas answer这对我有用

ls | while read aa
do
  git log -1 --format="%ai  $aa" "$aa"
done

最佳答案

$ 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

取自https://stackoverflow.com/a/469238/805284

如果这看起来很奇怪:
我的SHA1通过core.abbrev=4中的.gitconfig缩写为仅4个数字。

但是也许您可以在这里使用它:
$ 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

关于git - git ls文件与日期?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11648942/

10-15 03:26
查看更多