Skip to content

Instantly share code, notes, and snippets.

@campbellwmorgan
Created October 25, 2015 16:16
Show Gist options
  • Save campbellwmorgan/e8daaab4a7ebd1737c77 to your computer and use it in GitHub Desktop.
Save campbellwmorgan/e8daaab4a7ebd1737c77 to your computer and use it in GitHub Desktop.
Custom Sitechef config files for different git branches
#!/bin/bash
#######
# Enables branch-specific sitechef config files
# my moving data.json and .sitechef/.conf to subdirectories
# named after the branch name
#
# Installation
# Copy this file to your .git/hooks/ folder
######
set -e
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "After Checkout"
prevBranch=`git reflog | awk 'NR==1{ print $6; exit }'`
newBranch=`git reflog | awk 'NR==1{ print $8; exit }'`
echo "copy old files to $prevBranch"
cd "$scriptdir/../../.sitechef/"
mkdir "$prevBranch" || true
mkdir "$newBranch" || true
cp data.json "$prevBranch/"
cp .conf "$prevBranch/"
echo "copying new files to $newBranch"
cp "$newBranch/data.json" ./
cp "$newBranch/.conf" ./
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment