Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Created October 28, 2013 18:17
Show Gist options
  • Select an option

  • Save pcarrier/7201805 to your computer and use it in GitHub Desktop.

Select an option

Save pcarrier/7201805 to your computer and use it in GitHub Desktop.
Git snapshot to be pushed to a temporary ref
#!/bin/sh
TMP_INDEX="`mktemp .git/tmp_index.XXXXXX`"
trap "rm -f \"$TMP_INDEX\"" EXIT
rm -f "$TMP_INDEX"
GIT_INDEX_FILE="$TMP_INDEX" git add --all
TREE_ID=`GIT_INDEX_FILE="$TMP_INDEX" git write-tree`
COMMIT_ID=`echo "snapshot"|git commit-tree $TREE_ID`
echo $COMMIT_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment