Reputation: 222751
I have implemented a post-receive hook on my server (git was initialized with git init --bare
). Hook was created in the following way:
cd repo/hooks/
touch post-receive
chmod 777 post-receive
Then inside of the file I have:
#!/bin/sh
GIT_WORK_TREE=/var/www
export GIT_WORK_TREE
git checkout -f
Right now when I push my local changes everything gets moved to /var/www folder. The problem is that I do not want some of the folders to be moved. For example I have folder1
, and folder2
there which I do not want to be moved. Currently I am manually removing these folders after the push, but this is a ridiculous work and I would like to automate it.
I am on ubuntu 14.04
/ git 2.1
Upvotes: 1
Views: 538
Reputation: 1326636
I am manually removing these folders after the push
You could just ad this step in your hook
The other way is to try and set up a sparse checkout (since you can exclude folders in the sparse-checkout
file).
echo "/*" > .git/info/sparse-checkout
echo "!folder1/" >> .git/info/sparse-checkout
echo "!folder2/" >> .git/info/sparse-checkout
Upvotes: 2