Skip to content

Instantly share code, notes, and snippets.

@danmidwood
Last active October 3, 2015 14:47
Show Gist options
  • Save danmidwood/2471594 to your computer and use it in GitHub Desktop.
Save danmidwood/2471594 to your computer and use it in GitHub Desktop.
Check out commits in order, dumping commit messages in between.
#!/bin/bash
if [ -n "${1}" ]
then
startref=${1}..
fi
# Record the starting location, branch or hash
branch_name="$(git symbolic-ref HEAD 2>/dev/null)" || branch_name="$(cat .git/HEAD)"
branch_name=${branch_name##refs/heads/}
echo "Alright, let's roll. The revision hash will be displayed followed by the commit message. Once you're happy with the state, hit enter to move on."
# Read each line as a single revision. (by not splitting on spaces)
IFS=$'\n'
# For each revision, earliest first. Check it out, echo the commit message and wait for the user to hit a key before continuing
for revision in $(git log --pretty=oneline ${startref} --reverse)
do
git reset --hard -q $(echo ${revision} | cut -d' ' -f1) && echo ${revision} | cut -d' ' -f1 && echo ${revision} | cut -d' ' -f2-
git reset HEAD^
read notused
# Undo our reset HEAD^
git reset --hard -q $(echo ${revision} | cut -d' ' -f1)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment