如何获取Git中一堆文件的最后提交日期? [英] How to get the last commit date for a bunch of files in Git?
问题描述
获取Git仓库中一堆文件的最后一个提交日期(例如,对于每个文件,更改该文件的最后一次提交的日期),最简单的一行是什么?
其中的上下文是我使用其他Bash命令来查找符合某些条件的长文件列表,并且我想将这个列表管理到Git命令中以获取最后一个为每个文件提交日期。
以下命令会有帮助:
git log -1 --format =%cd filename.txt
这将打印一个文件的最新更改日期。 -1
显示一个日志条目(最近的), - format =%cd
显示提交日期。请参阅 git-log
,以获得对这些选项的完整说明。
您应该可以轻松地将其扩展为一组文件。
What's the simplest one-liner to get the last commit date for a bunch of files in a Git repository (i.e., for each file, the date of the last commit that changed that file)?
The context for this is that I'm using other Bash commands to find a long list of files matching some criteria, and I'd like to just pipe this list into a Git command to get the last commit date for each file.
The following command will be helpful:
git log -1 --format=%cd filename.txt
This will print the latest change date for one file. The -1
shows one log entry (the most recent), and --format=%cd
shows the commit date. See the documentation for git-log
for a full description of the options.
You should be able to easily extend this for a group of files.
这篇关于如何获取Git中一堆文件的最后提交日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!