diff --git a/README.md b/README.md index cab6368..087633a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1811 TILs and counting..._ +_1812 TILs and counting..._ See some of the other learning resources I work on: @@ -395,6 +395,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Interactively Unstage Changes](git/interactively-unstage-changes.md) - [Keep File Locally With `git rm`](git/keep-file-locally-with-git-rm.md) - [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md) +- [List All Authors On Git Repository](git/list-all-authors-on-git-repository.md) - [List All Files Added During Span Of Time](git/list-all-files-added-during-span-of-time.md) - [List All Files Changed Between Two Branches](git/list-all-files-changed-between-two-branches.md) - [List All Git Aliases From gitconfig](git/list-all-git-aliases-from-gitconfig.md) diff --git a/git/list-all-authors-on-git-repository.md b/git/list-all-authors-on-git-repository.md new file mode 100644 index 0000000..ab9dbc3 --- /dev/null +++ b/git/list-all-authors-on-git-repository.md @@ -0,0 +1,68 @@ +# List All Authors On Git Repository + +The `git log` is the ledger of all commits made to the repository. If I am on +the `main` branch and I have the latest pulled from the remote, then running +`git log` will be a complete listing of all commits. + +`git log` includes more information than just authorship. I can narrow that all +down to only author name and author email using the `--format` flag. For all the +format string options available, I can run `man git-log` and jump to the `PRETTY +FORMATS` section, scrolling just past the built-in formats. + +The two I am interested in are `%an` (Author Name) and `%ae` (Author Email). I +can arrange these however I want in the format string argument. Here is what it +looks like for the [`egghead-next` +project](https://github.com/skillrecordings/egghead-next): + +```bash +❯ git log --format='%an <%ae>' +Zac Jones +Zac Jones +Zac Jones +Zac Jones +Zac Jones +Zac Jones +Zac Jones +John Lindquist +Zac Jones +... +``` + +I get _name_ followed by _email_ wrapped in angle brackets. This is only so +useful though because I am going to see tons duplicate authors especially for a +project with hundreds and thousands of commits. I can narrow this down with [a +deduplication trick via +`awk`](unix/deduplicate-list-while-preserving-original-order.md): + +```bash +❯ git log --format='%an <%ae>' | awk '!seen[$0]++' +Zac Jones +John Lindquist +Josh Branchaud +Vojta Holik +Creeland A. Provinsal +joel +Creeland +... +``` + +That's already a big improvement. The only other change I want to make is +related to the default ordering of `git log`. It lists out commits in descending +order (most recent first). I want to see authors listed in the order that they +first committed to the project. Adding in the `--reverse` flag will solve for +that. + +```bash +❯ git log --reverse --format='%an <%ae>' | awk '!seen[$0]++' +Joel Hooks +johnlindquist +John Lindquist +William Johnson +depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> +Evgeniy Nagalskiy +Taylor Bell +Maggie Appleton +... +``` + +See `man git-log` for more details.