简体   繁体   English

如何获得文件所有权,即每个开发人员为应用程序的每次提交添加的代码行

[英]How to get file ownership i.e lines of code added by each developer per commit for an application

I tried below statement 我尝试了以下声明

git blame --line-porcelain file | git blame --line-porcelain文件| sed -n 's/^author //p' |sort | sed -n's / ^ author // p'|排序| uniq -c | uniq -c | sort -rn 排序-rn

but this statement gives for the latest commit . 但是该语句给出了最新的提交。 I need for each and every commit for a particular file. 我需要特定文件的每次提交。

Please suggest !! 请建议!

You can use this sequence 您可以使用此顺序

git log --reverse --oneline filename | awk '{ print $1; }'| while read c
do echo "authors for commit $c:"
    git blame --line-porcelain filename $c | grep "^author " | sort | uniq -c | sort -nr
done

As I told you: This is a multi dimensional thing with coordinates (filename, commit, author, number of lines) . 正如我告诉您的:这是一个具有坐标(filename, commit, author, number of lines)多维事物。 First think about how you want to display or store the output. 首先考虑一下您要如何显示或存储输出。 Also note that git blame is not about added lines but changed lines. 还要注意, git blame不是关于添加的行,而是关于更改的行。 So if someone deleted a file with 10k lines, he/she will get noted as a changer of 10k lines, though the statement was just rm file . 因此,如果某人删除了一个具有10k行的文件,尽管该语句只是rm file ,但他/她将被记录为10k行的rm file

Number of Lines changed is generally a very bad parameter to measure code or work done on some code. 更改的行数通常是衡量代码或对某些代码完成的工作的非常糟糕的参数。 Sometimes an author that thinks a week over his code and then changes one line, improving the speed of the program by a factor of 1000 is a much worthier author than this guy last week, who wrote 5000 lines of spagetthi code. 有时候,一个写作者考虑一周的代码然后更改一行代码,从而将程序速度提高1000倍的作者,比上个星期写了5000行spagetthti代码的那个家伙要有价值得多。

But this information is redundant. 但是这些信息是多余的。 Better use 更好地使用

git log -p --reverse filename

and learn to read patch files. 并学习阅读补丁文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我怎样才能在 git 中获取文件的每次提交的代码行 - How can i get the line of code per commit for a file in git 如何在git repo中每次提交后确定每个文件中的代码行数 - How to determine the number of lines of code in each file after each commit in a git repo 如何获取git log来限制每条提交消息的行数? - How can I get git log to limit the number of lines per commit message? 我如何获得每次提交的代码行 - How I can get line of code for each commit 每天和每个开发人员的代码提交量图 - Per day and per developer Graph of Code commit volume 如何计算git中从第一次提交(初始提交)到最后一次提交添加和修改的行数? - How can I calculate the number of lines added and modified from First commit(initial commit) to Last commit in git? 如何将特定文件中添加的最后提交代码添加到另一个临时文件 - How to get last commit code added in a particular file to another temp file 为什么git有时将添加的行标记为已更改的行(即,在添加的代码上出现空冲突) - Why does git sometimes mark added lines as changed lines (i.e. an empty conflict over an added piece of code) 如何获得每个开发人员在所有分支上的提交次数? - How can I get number of commits on ALL branches per developer? 如何查看在特定提交中添加到文件的内容? - How can I view what was added to a file in a certain commit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM