Git:如何列出版本控制下的所有文件及其作者日期? [英] Git: how to list all files under version control along with their author date?
问题描述
为了做到这一点,我想让git输出一个列表版本控制下的所有文件以及每个文件的作者日期。从 git ls-files
或 git ls-tree -r master
的输出将是完美的,前提是它们的输出包含时间戳
有没有办法从git获得这个输出?
Update for更多的上下文:我有一个当前的实现,它包含一个python脚本,它遍历源代码管理下的每个文件并在每个文件上执行 git log
,但是我发现这并不好。回购中的文件越多,我必须进行的
版本控制下的所有文件以及每个文件的作者日期列表
缩放并不是问题用这个:
#!/ bin / sh
temp =$ {TMPDIR: - / tmp} / @@@ commit-at @@@ $$
traprm'$ temp'0 1 2 3 15
git log --pretty = format:%H%x09%at - -topo-order --reverse$ @>$ temp
cut -f1$ temp\
| git diff-tree -r --root --name-status --stdin \
| awk'
BEGIN {FS =\t; OFS =\ t}
FNR == 1 {++ f}
f == 1 {at [$ 1] = $ 2;下一个}
NF == 1 {commit = $ 1;下一个}
$ 1 ==D{$ 1 =;删除最后[$ 0];下一步}#注释也显示已删除的文件
{did = $ 1; $ 1 =; last [$ 0] = at [commit]\ tdid}
END {for(f in last)print last [f] f}
'$ temp - \
| sort -t`printf'\t'`-k3
Given a git repo, I need to generate a dictionary of each version controlled file's last modified date as a unix timestamp mapped to its file path. I need the last modified date as far as git is concerned - not the file system.
In order to do this, I'd like to get git to output a list of all files under version control along with each file's author date. The output from git ls-files
or git ls-tree -r master
would be perfect if their output had timestamps included on each line.
Is there a way to get this output from git?
Update for more context: I have a current implementation that consists of a python script that iterates through every file under source control and does a git log
on each one, but I'm finding that that doesn't scale well. The more files in the repo, the more git log
calls I have to make. So that has led me to look for a way to gather this info from git with fewer calls (ideally just 1).
a list of all files under version control along with each file's author date
Scaling isn't a problem with this one:
#!/bin/sh
temp="${TMPDIR:-/tmp}/@@@commit-at@@@$$"
trap "rm '$temp'" 0 1 2 3 15
git log --pretty=format:"%H%x09%at" --topo-order --reverse "$@" >"$temp"
cut -f1 "$temp" \
| git diff-tree -r --root --name-status --stdin \
| awk '
BEGIN {FS="\t"; OFS="\t"}
FNR==1{++f}
f==1 {at[$1]=$2; next}
NF==1 {commit=$1; next}
$1=="D"{$1=""; delete last[$0]; next} # comment to also show deleted files
{did=$1;$1=""; last[$0]=at[commit]"\t"did}
END {for (f in last) print last[f]f}
' "$temp" - \
| sort -t"`printf '\t'`" -k3
这篇关于Git:如何列出版本控制下的所有文件及其作者日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!