DEV Community

loading...

Git users and their last commits

bearcherian profile image Bear Cherian Updated on ・1 min read

I needed to remember who was working with me on a certain project over the last year. I had some trouble remembering, because this last year has been crazy personally, and the project overlapped a couple years. All the years and months and days were running together in my brain.

Fortunately, we have git logs, but it's not straightforward. I came up with this set of commands to help with the task:

git log --pretty=format:"%an" | sort | uniq | awk '{system("git log -1 --author="$1 " --pretty=format:\"%ad%x09%an\""); print "\r"}' | sort -k5n -k2M -k3n

Here's what we're doing:

  1. get all of the user names in the git logs
  2. sort them lexically
  3. remove repeats (sort -u could have replaced these)
  4. do another git log for each user, but print out their last commit, and format it to be just the date and their name separated by a tab.
  5. Sort by the columns (year, month, date)

Discussion (0)

pic
Editor guide