function report(){
file=$1
#commit=$(git log -1 --pretty=%H -- "$file")
#Edit: use the following command instead, in order to deal with file paths with a space.
commit=$(git log -1 --pretty=%H -- "$file")
#if you want to ignore the files unchanged since the root commit, you could use:
#commit=$(git log -1 --pretty=%H --min-parents=1 -- "$file")
authorname=$(git log -1 $commit --pretty=%an)
commitdate=$(git log -1 $commit --pretty=%cd --date=short)
commitcomment=$(git log --format=%b -n 1 $commit)
status=$(git show $commit --pretty=%h --name-status | grep "$file" | awk '{print $1}')
case $status in
A) status=Added;;
C) status=Copied;;
D) status=Deleted;;
M) status=Modified;;
R) status=Renamed;;
T) status=Changed;;
U) status=Unmerged;;
B) status=Broken;;
*) status=Unknown;;
esac
echo "$commit|$file|$authorname|$commitdate|$status|$commitcomment"
}
#git ls-files | while read line; do report $line; done > report.txt
#Edit:use the following command instead, in order to get all files, including deleted files.
git log --pretty="/ %h" --name-only | grep -v ^$ | grep -v "/ " | sort -u | while read line;do report "$line"; done; > report.txt
、その後、次の方法でフィールドをspliting、ExcelにREPORT.TXTをインポートすることができ '|'。
私のコードは十分に効率的ではないかもしれませんが、動作します。
これは 'git ls-tree --recursive'とその後の' git log'を使った処理を含む簡単なスクリプトでなければなりません。これまでに何を試しましたか? – user3159253
@ user3159253、私はgit log/git showを--pretty = "%cn、%cd"で試しました。 - オンライン;および--name-status。寄稿者名と日付をファイル名とステータスで組み合わせるオプションを見つけることができないようです。これらのペアは排他的なようですか?私はgitbashに新しいです。 – Quicksilver