Voloda2
Voloda2

Reputation: 12627

How do I log unique authors in git?

I have a big project with many authors.

For example,

user1 - commit1
user2 - commit2
user1 - commit3 

I want to get all unique authors. The result must be user1 user2

How do I log unique authors in git?

Upvotes: 20

Views: 4887

Answers (4)

Patrick DeVivo
Patrick DeVivo

Reputation: 795

Another possibility is gitqlite "SELECT DISTINCT author_name FROM commits" using gitqlite, which is a tool for running ad-hoc SQL queries on git data.

(Full disclosure, I'm a creator/maintainer of the project)

Upvotes: 0

Roger Perez
Roger Perez

Reputation: 3149

I needed to get the authors and committers so below is the https://devhints.io/git-log to helpful commands.

code below gets you the author name (%an) and author email (%ae) in this format

personName - [email protected]

git log --format="%an - %ae" | sort -u
git log --format="%cn - %ce" | sort -u

Upvotes: 3

Renato Zannon
Renato Zannon

Reputation: 30021

Try out this one:

 git shortlog -s | awk '{print $2,$3}' | sort -fu

Edit: This will get you the emails as well

git shortlog -se | sed -re 's/^\s*[[:digit:]]*\s*//' | sort -fu

or, on macOS without the -r flag - highlighted by Oliver in comments below - would be:

git shortlog -se | sed -e 's/^\s*[[:digit:]]*\s*//' | sort -fu

Upvotes: 10

Stuart Golodetz
Stuart Golodetz

Reputation: 20656

Here's one easy way:

git log --format="%an" | sort -u

Upvotes: 42

Related Questions