Skip to content

Instantly share code, notes, and snippets.

@gajoseph
Created May 2, 2018 01:47
Show Gist options
  • Save gajoseph/c46d093f0d88e6560f0796aa1798f02d to your computer and use it in GitHub Desktop.
Save gajoseph/c46d093f0d88e6560f0796aa1798f02d to your computer and use it in GitHub Desktop.
/*
to copy/ archive changed files on git commit to local repository this might help
in my case need was to copy to /r/edt/Data\ and\ Analytics/deploy/
git hooks are located under .git\hooks under local respository
tosetup::
$git lfs update
$ git lfs update --force
then update .git/hooks/post-comit
*/
#!/bin/sh
git diff --name-only HEAD^ > /c/tmp/updated.txt ## gives chnaged files
filename="/c/tmp/updated.txt"
pathtoCp=/r/edt/Data\ and\ Analytics/deploy/
while read -r line
do
#echo $line
name=$(echo $line | awk -F"/" '{print $1}')
#echo $name;
if [ "$name" == "PHASE1" ]
then
echo " Copying $line to $pathtoCp""Phase\ 1"
echo $line| xargs -i cp {} "$pathtoCp"Phase\ 1
else
if [ "$name" == "PHASE2" ]
then
echo " Copying $line to $pathtoCp""Phase\ 2"
echo $line | xargs -i cp {} "$pathtoCp"Phase\ 2
else
if [ "$name" == "PHASE3" ]
then
echo " Copying $line to $pathtoCp""Phase\ 3"
echo $line | xargs -i cp {} "$pathtoCp"Phase\ 3
fi
fi
fi
done < "$filename"
@gajoseph
Copy link
Author

nice

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