![](/img/trans.png)
[英]How to check file/directory changes of a multi directory git repository between two git commits?
[英]How to list the original commits (time and author) per file of a directory with git?
我想用 git 列出我(以ls
風格):
我正在尋找這樣的輸出:
File Original Author First Added Commit
----------------------------------------------------------------
a.yaml tom 01/01/2020 1a12121
b.yaml felix 05/01/2020 ad12257
[...]
他用 git 有什么可能嗎?
您可以使用git log --pretty-format
和--diff-filter=A
( A
表示添加):
#!/bin/bash
echo "File Original Author First Added Commit"
echo "----------------------------------------------------------------"
if [[ $# -eq 0 ]]; then
# No arguments, list all in current directory
files=(*)
else
# Only show those supplied on the command line
files=("$@")
fi
for file in "${files[@]}"
do
if [[ -f $file ]]; then
msg=$(git log --diff-filter=A --pretty=format:'%al %as %h' "$file")
printf "%-17s %-20s %-17s %s\n" "$file" $msg
fi
done
例子:
File Original Author First Added Commit
----------------------------------------------------------------
CMakeLists.txt ted 2020-06-24 41b5c92
LICENSE ted 2019-06-25 39d3ad5
README.md ted 2019-06-25 0bfa2a3
TODO ted 2020-01-13 aaeea10
--pretty-format
支持幾種日期格式,雖然我找不到你的確切格式,它也支持許多不同的版本來顯示作者姓名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.