Skip to content

Instantly share code, notes, and snippets.

@JanDeDobbeleer
Created July 18, 2014 19:34
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 JanDeDobbeleer/4d94cb047ed86cc556a6 to your computer and use it in GitHub Desktop.
Save JanDeDobbeleer/4d94cb047ed86cc556a6 to your computer and use it in GitHub Desktop.
script to copy the working directory from the master after a commit to your cloud storage account to allow automatic backups
#!/bin/sh
# only deploy when on the master
# add this file to .git/hooks in your repo
# add your preferred cloud storage account
dest="Dropbox"
branch=$(git rev-parse --abbrev-ref HEAD)
if [ "master" == "$branch" ]; then
echo "Deploying to $dest"
unset GIT_INDEX_FILE
# change this to your cloud storage location
export GIT_WORK_TREE=C:/Operations/Dropbox
# change this to your repo
export GIT_DIR=C:/Users/janjoris/Documents/Git/Operations/.git/
git checkout -f
else
echo "Not on master, deploy to $dest cancelled"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment