Skip to content

Instantly share code, notes, and snippets.

@judofyr
Created June 2, 2015 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save judofyr/9e3b48bd045bc60ba1ed to your computer and use it in GitHub Desktop.
Save judofyr/9e3b48bd045bc60ba1ed to your computer and use it in GitHub Desktop.
set -e
DIR="docs"
BRANCH="gh-pages"
# Stage all files in the directory
find "$DIR" -type f | xargs git update-index --add
# Write the sub-tree
TREE=$(git write-tree --prefix="$DIR")
# Commit the tree
COMMIT=$(git commit-tree "$TREE" -m 'update docs' -p "$BRANCH")
# Update branch to the new commit
git branch -f "$BRANCH" "$COMMIT"
# Unstage files again
find "$DIR" -type f | xargs git update-index --remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment