Skip to content

Instantly share code, notes, and snippets.

@japboy
Created June 29, 2013 14:47
Show Gist options
  • Save japboy/5891379 to your computer and use it in GitHub Desktop.
Save japboy/5891379 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Update a specific branch to include content from specific directory
BRANCH='gh-pages'
DIRECTORY='gh-pages'
BRANCH_SHA=$(git show-ref -s refs/heads/${BRANCH})
DIRECTORY_SHA=$(git ls-tree -d HEAD ${DIRECTORY} | awk '{print $3}')
COMMIT=$(echo 'Auto-update.' | git commit-tree ${DIRECTORY_SHA} -p ${BRANCH_SHA})
git update-ref refs/heads/${BRANCH} ${COMMIT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment