git ls-files按修改时间排序 [英] git ls-files sort by modification time

查看:672
本文介绍了git ls-files按修改时间排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何列出按修改时间排序的文件?



我想要git修改时间,而不是系统修改时间。例如,如果我有(提交)文件 README ,那么

  touch README 

会改变系统修改时间...但git状态将保持不变。 / p>

如果我尝试

  git ls-files -z | xargs -0 ls -t 

这将按系统修改时间排序。



有没有选择 git ls-files 可以列出按其git修改时间排序的文件?



是否有任何选项可以列出文件 git ls-files


排序他们的git修改时间?

我不这么认为。一种可能的方式是迭代文件,使用 git log sort 输出获取时间戳。 / p>

以下内容可能适用于您:

 读取档案时;做echo $(git log --pretty = format:%ad -n 1 --date = raw  -  $ file)$ file;完成< <(git ls-tree -r --name-only HEAD)| sort -k1,1n 


How can I list files sorted by their modification time?

I want the git modification time, not the system modification time. For example, if I have a (committed) file README, then

touch README

will change the system modification time... but the git status would remain unchanged.

If I try

git ls-files -z | xargs -0 ls  -t

this will sort by the system modification time.

Is there any option to git ls-files that would list files sorted by their git modification time?

解决方案

Is there any option to git ls-files that would list files sorted by their git modification time?

I don't think so. One possible way would be to iterate over the files, get the timestamp using git log, and sort the output.

The following might work for you:

while read file; do echo $(git log --pretty=format:%ad -n 1 --date=raw -- $file) $file; done < <(git ls-tree -r --name-only HEAD) | sort -k1,1n

这篇关于git ls-files按修改时间排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆