Created
May 3, 2024 18:27
-
-
Save s-h-a-d-o-w/841bb5e848872b510cef5770467e2f5a to your computer and use it in GitHub Desktop.
Search the git commit history for a string, with optional duration limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt 1 ]; then | |
echo "Usage: $0 <search-string> [last X days]" | |
exit 1 | |
fi | |
if [ "$#" -eq 1 ]; then | |
git --no-pager log --grep="$1" | |
else | |
START_DATE=$(date --date="$2 days ago" '+%Y-%m-%d') | |
git --no-pager log --since="$START_DATE" --grep="$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment