Skip to content

Instantly share code, notes, and snippets.

@speters
Created September 10, 2015 18:44
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 speters/0138046f1208b44cb5be to your computer and use it in GitHub Desktop.
Save speters/0138046f1208b44cb5be to your computer and use it in GitHub Desktop.
git post-commit hook script to copy a subdirectory of the repo to another folder
#!/bin/sh
# copy a subdirectory of a repository to another location after commit
DESTINATIONDIR=/usr/share/arduino/libraries
# subdirectory in repo to copy:
CHECKOUTSUBDIR=TMRpcm
mkdir /tmp/bla
unset GIT_INDEX_FILE
GIT_WORK_TREE=${DESTINATIONDIR} git checkout -f -- ${CHECKOUTSUBDIR}
@speters
Copy link
Author

speters commented Oct 26, 2015

blah=`sed -n -e '/^name=/{ s/^name=//gp;q0};q1' < library.properties` || blah=`sed -n -e '/^Unnamed repository/{s/;.*//g;p;q1};q0' < .git/description` || blah=$(cd ".git/.."; basename $(pwd)) ; echo $blah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment