Skip to content

Instantly share code, notes, and snippets.

@kwk
Last active June 4, 2023 14:31
Show Gist options
  • Save kwk/63d61946ad275084f778 to your computer and use it in GitHub Desktop.
Save kwk/63d61946ad275084f778 to your computer and use it in GitHub Desktop.
Aliases to quickly find git commits made in quarter of a year
[alias]
# List your commits by quarters of a year in reverse order (short version)
q1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --oneline --reverse $@; }; f"
q2 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"April $year\" --until \"June $year\" --oneline --reverse $@; }; f"
q3 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"July $year\" --until \"September $year\" --oneline --reverse $@; }; f"
q4 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"October $year\" --until \"December $year\" --oneline --reverse $@; }; f"
# List your commits by quarters of a year in reverse order (long version)
quarter1 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"January $year\" --until \"March $year\" --reverse $@; }; f"
quarter2 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"April $year\" --until \"June $year\" --reverse $@; }; f"
quarter3 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"July $year\" --until \"September $year\" --reverse $@; }; f"
quarter4 = "!f() { year=$1; shift; git log --author \"$(git config --get user.name)\" --since \"October $year\" --until \"December $year\" --reverse $@; }; f"

README

Add this snippet to your global ~/.gitconfig file to simply query commits per quarter of a year.

Usage

git (q1|q2|q3|q4|quarter1|quarter2|quarter3|quarter4) (2012|2013|2014...any year)

  • will list all of your commits (based on your user name)
  • that you've made from
  • q1|quarter1 January to March
  • q2|quarter2 April to June
  • q3|quarter3 July to September
  • q4|quarter4 October to December
  • in chronological order
  • with one line per commit (use git quarter1 2012 for the full message)
  • all additional parameters after the year will be passed to the git log command that is used to implement this macro
  • for example, git q2 2010 --patch lists all diffs for each commit.
@kwk
Copy link
Author

kwk commented Oct 24, 2022

I recommend using https://github.com/psss/did instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment