title | description | date | date-meta | github-comments |
---|---|---|---|---|
Use Git CLI to find folder last changed date |
Curious about which folders you've worked on recently and which folders have been gathering dust in a Git project? Use Git CLI to find the last date the folder has been changed. |
April 2023 |
2023-04-10 |
I have a folder in git that contains all my projects. I wanted to find which projects I haven't worked on in a while to clean them up, so I made this command.
ls -1 projects
dnd
home-server
learn-japanese
find projects -maxdepth 1 -type d \( ! -name . \) -exec git log --pretty=format:'%ad {}' --date=format:'%Y-%m-%d' -1 {} \; -exec echo \; | sort
2019-12-05 home-server
2023-01-07 learn-japanese
2023-04-08 dnd
find projects -maxdepth 1 -type d \( ! -name . \) \
-exec git log --pretty=format:'%ad {}' --date=format:'%Y-%m-%d' -1 {} \; \
-exec echo \; \
| sort
%ad
is the date-1
looks at a single commit per folder
git log --pretty=format:'%ad projects/home-server' --date=format:'%Y-%m-%d' -1 projects/home-server
https://www.jarett-lee.com/blog/git-cli-folder-last-changed-date/