Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git blame a list of authors in a file

Tags:

git

bash

Is there a way to find out a list of authors who edited the class in java file in repo using git blame? The list of authors have to be unique.

I have tried using the following command but it did not remove duplicates and there is word "author" in every line of output. There is no need to sort the output, but I hope to get output without any duplicates.

git blame filename --porcelain | grep  "^author "

Expected output should be just author name: John Michael

like image 725
stackyyflow Avatar asked Sep 17 '16 16:09

stackyyflow


People also ask

How do I blame a file in git?

The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was. If there was a bug in code,use it to identify who cased it,then you can blame him. Git blame is get blame(d).

How do I blame a specific line in git?

Blaming only a limited line range Sometimes, You don't need to blame the entire file, you just need to blame in a limited line range. Git blame provides the option for that. -L will take the option for the start line and for the end line. The above command will blame from line 80 through line 100.

Does git blame show lines that were deleted or replaced?

The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as git diff or the "pickaxe" interface briefly mentioned in the following paragraph.

How do I git blame on GitHub?

On GitHub.com, navigate to the main page of the repository. Click to open the file whose line history you want to view. In the upper-right corner of the file view, click Blame to open the blame view.


1 Answers

You can add at the end of the command uniq to make author unique.

git blame filename --porcelain | grep  "^author " | sort -u

sort Documentation

like image 173
Flows Avatar answered Sep 28 '22 15:09

Flows