The intention of writing this script is to help lookback at work and share like https://twitter.com/PaiNishant/status/1680105589513543682
How to use:
- Save script
- Open the terminal
- Go to repo
- Run /path/replay.sh abcd123
if you do
/path/replay.sh
without params it'll run from the beginning
#!/bin/bash
# Usage: replay.sh [start_commit]
START_COMMIT=$1
i=0
head=$(git rev-parse HEAD)
if [[ -n $START_COMMIT ]]; then
# Checkout the starting commit
git checkout "$START_COMMIT"
fi
# Take 5 seconds to prepare
echo "Preparing to replay commits in 5 seconds"
sleep 5
for commit in $(git log --reverse --pretty=format:%H)
do
if [[ -n $START_COMMIT && $commit == $START_COMMIT ]]; then
START_COMMIT=""
fi
if [[ -z $START_COMMIT ]]; then
echo "Replaying commit $commit"
git checkout "$commit"
i=$((i+1))
echo "Commit $i of $(git rev-list --count HEAD)"
# If any data takes 5 seconds to load
sleep 10
fi
done
# Go back to the HEAD of the current branch
git checkout "$head"