Created
January 3, 2022 16:33
-
-
Save d4hines/92462bd08506a8fed628662aa93f16a9 to your computer and use it in GitHub Desktop.
iterate commits one by one
This file contains hidden or 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
#!/usr/bin/env bash | |
# Used to go through each commit in a repo one by one | |
# for exploratory purposes. | |
git reset --hard HEAD | |
git clean -xfd | |
INDEX=$(cat /tmp/index) | |
INDEX=$(($INDEX + 1)) | |
echo $INDEX > /tmp/index | |
TOTAL=$(git rev-list --branches main | wc -l) | |
NEXT=$(($TOTAL - $INDEX)) | |
COMMIT=$(git rev-list --branches main | sed "${NEXT}q;d") | |
git co $COMMIT | |
git reset --soft HEAD~1 | |
echo "==== Now showing commit $INDEX/$TOTAL ====" | |
git rev-list --pretty=medium --max-count=1 $COMMIT | tee /tmp/message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment