git command —— git blame & git show -status & git 管道操作:| ——找到谁修改的 & 找到 某次commit 涉及的文件
$ git show --stat 991398f8 --pretty=format:%f | awk '{print $1}' | awk 'NR>2{print p}{p=$0}' Doc/TestData/CashDistribution.csv Doc/TestData/CashPreAuthorization.csv Doc/TestData/CashReturn.csv Doc/TestData/CashTRXRefundRequest.csv Doc/TestData/CashTransactionHistory.csv Doc/TestData/DomainProtection.csv
991398f8 :为 commit id
stat命令用于显示文件的状态信息
--pretty=format :表示显示格式
命令help:
$ git show --help
相关资料:https://gist.github.com/Alpha59/4e9cd6c65f7aa2711b79#file-creditwherecreditisdue-sh
A very very slow one-liner that goes through a git blame and sees how many lines were contributed by each author.
# creditwherecreditisdue.sh git ls-files -z | xargs -0n1 git blame -wfn | grep -v "test" | grep "\.(js|html)[^o]\s" | perl -n -e '/\((.*)\s[\d]{4}\-/ && print $1."\n"' | awk '{print $1" "$2" "$3}' | sort -f | uniq -c | sort -nr # Lists the number of lines that an author has contributed to the code base. # This also filters for !test and ==.js or .html (which was useful for this particular run) # A Django version of the same thing: git ls-files -z | xargs -0n1 git blame -wfn | grep -v "test" | grep -v "fixture" | grep -v "json" | grep -v "gpg" | grep -v ".md" | grep -v "initial_schema" | grep -v "fonts" | grep -v "min." | grep -v "migrations" | grep -v "images" | grep -v "/bootstrap" | grep -v "debug" | grep -v "/img" | grep -v "vendor" | perl -n -e '/\((.*)\s[\d]{4}\-/ && print $1."\n"' | awk '{print $1" "$2" "$3}' | sort -f | uniq -c | sort -nr # removemergedbranches.sh git branch --merged | grep -v `git rev-parse --abbrev-ref HEAD` | xargs git branch -d # checkout your dev branch, and then clean up your local by running this to remove all merged branches. # whatdidtheywrite.sh git ls-files -z | xargs -0n1 git blame -wfn | awk '/<author>/{print $0}' # I suggest only using this if the author has a small number of lines listed above. # I also adjusted it to include the file name and line number. # whatfilesdidtheychange.sh git ls-files -z | xargs -0n1 git blame -wfn | awk '/<author>/{print $2}' | sort -f | uniq -c | sort -nr # Lists out files that have been altered by a given author (including number of lines changed in that file).
xargs :分隔符操作
awk:字符操作
$ git blame Source/service.json -wfn ca12140a9da Source/service.json 1 (dxu 2020-07-07 18:57:06 +0800 1) { ca12140a9da Source/service.json 2 (dxu 2020-07-07 18:57:06 +0800 2) "DockerEnv": { git blame Source/service.json -wfn | awk '{print $4}' (dxu (dxu
$ git blame --help
-w
Ignore whitespace when comparing the parent’s version and the child’s to find where the lines came from.
-f
--show-name
Show the filename in the original commit. By default the filename is shown if there is any line that came from a file with a different name, due to rename detection.
-s
Suppress the author name and timestamp from the output.