#!/bin/sh set -e # git snap: (re-)commit a snapshot of exactly another commit # an alternative to 'pick' in git rebase -i: use x git snap if [ -z "$1" ]; then echo "usage: git snap " exit fi case `git cat-file -t $1` in commit) ;; *) echo "$1 is not a git commit" exit ;; esac SHA=$1 git read-tree $SHA^{tree} git commit -C $SHA | head -n1 git reset --hard --quiet