Update: I made this into a bash script that has sensible defaults (
gitlog for today's log) and a few tricks (e.g.,
gitlog yesterday to yank yesterday's log into the clipboard).
This is probably the most satisfying command-line lifehack of the year for me:
git log --author=Nate --since=1.day.ago --all-match --format='%s' | tail -r | paste -s -d : - | sed -e 's/:/; /g' | pbcopy
This takes all your commit messages for the last day, concatenates them with a semicolon, and shoves them into your clipboard to paste into Harvest (or On The Job if I’m working freelance).
git logoptions seem pretty obvious except
--format='%s'which outputs just the commit message on each line
tail -rreverses order of lines
paste -s -d : -concatenates & separates each line with a colon
sed -e 's/:/; /g'replaces the colon with a semicolon and a space (couldn’t figure out a way to do this in one command)
pbcopyshoves the result into your clipboard on OS X
I’m guessing there’s a slightly prettier way to do this, but there’s a reason I keep trying to get everyone to start calling me Hacksaw because I’ve always really wanted a nickname and then I could get a tattoo.
You can also do a a custom span of time e.g.
--since=3.days.ago --until=1.day.ago if you want more than just the last day of commits.
If you are in the thick of push battles with your coworker on a project and want to avoid the “Merge branch” lines from git, you can just add
sed '/Merge branch/d' to the mix:
git log --author=Nate --since=1.day.ago --all-match --format='%s' | sed '/Merge branch/d' | tail -r | paste -s -d : - | sed -e 's/:/; /g' | pbcopy