Show the latest git commit for all projects on your local machine

If you are anything like me, you sometimes loose track of the work you have done over the last week or so. To get a good overview of the projects you have worked on, just create a bash file like gitlog.sh and run it. Or just copy the entire command, paste it in your terminal and hit [ENTER].

This command gives you a nice list of the latest git commit on every project, most recent project you worked on is at the top of the list.

I have about 200GB worth of projects on my local machine and this command only takes a couple of seconds to run.

#!/bin/bash

SITES_PATH='/Users/joostvanveen/htdocs'
NUM_PROJECTS=40
NUM_COMMITS_PER_PROJECT=1

# --- DO NOT EDIT BELOW THIS LINE cd $SITES_PATH
GITLOG_FILE=$SITES_PATH/.gitlog.txt echo '' > $GITLOG_FILE for folder in */; do cd $folder; git log --pretty=format:"%cd [$folder] - %an - %s" --date=short 2> /dev/null | head -$NUM_COMMITS_PER_PROJECT >> $GITLOG_FILE; cd ../; done cat $GITLOG_FILE | uniq | sort -r | head -$NUM_PROJECTS

Typical output:

2021-04-23 [MY-SPECIAL-PROJECT/] - Joost van Veen - Ticket 11949 : pop up stays hidden after being clicked away. Is displayed again after X page loads
2021-04-22 [MY-SECRET-PROJECT/] - Joost van Veen - Release 8.3.1
2021-04-21 [MY-SIDE-PROJECT/] - Joost van Veen - Created some script