Git deploy script

The script grab new files (after “git add”) and modified files and copy them to a new directory “deploy”.

git status | grep "modified\|new file" | awk '{print $3}' | while read file; do mkdir -p `dirname deploy/"$file"`; cp $file deploy/$file; done

Or, use this to create the deploy folder for commits done in the last 2 days: (the code may generate some error output saying certain files don’t exist, because it’s trying to copy the files you deleted in commits, they are harmless just too lazy to put check in)

git whatchanged --since "2 days ago" | grep ^: | awk '{print $6}' | sort | uniq -c | awk '{print $2}' | while read file; do mkdir -p `dirname deploy/"$file"`; cp $file deploy/$file; done

Leave a Reply