Skip to content

Instantly share code, notes, and snippets.

@Manishearth
Last active August 22, 2019 20:39
Show Gist options
  • Save Manishearth/fb2caccbadf4aa683fa2a7496dfbfee3 to your computer and use it in GitHub Desktop.
Save Manishearth/fb2caccbadf4aa683fa2a7496dfbfee3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Make it exit early if there's an error
set -e
# cd git root
pushd $(git rev-parse --show-toplevel) >/dev/null
PINKY_FILE=$(git rev-parse --git-path pinky)
# Create a new scratch index based on the existing index
cp $(git rev-parse --git-path index) ${PINKY_FILE}
# Add all files to scratch index. Use -u if you don't want to include untracked files
GIT_INDEX_FILE=${PINKY_FILE} git add .
# Write pinky index to a tree object, create a commit from it with parent=HEAD
echo "jane" | git commit-tree $(GIT_INDEX_FILE=${PINKY_FILE} git write-tree) -p @
# Clean up
rm ${PINKY_FILE}
# cd back
popd >/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment