I have a question about how to start using automatic deployments after the git repo on our client's site has been wiped out.
What happened to the repo? The client wanted to use a feature on their hosting provider where they can make copy edits to a staging site and "push" it to the live site. After they pushed edits, the git repo disappeared.
Automatic deployments: We're using git hooks do deployments. Here's a good how-to. Basically, you can make deployments locally using git push <environment> <branch>
. When you run this command, git runs the following post-receive
hook (site name removed for privacy):
#!/bin/bash
TARGET="/www/[sitename]_571/public"
GIT_DIR="/www/[sitename]_571/private/[sitename].git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [[ $ref = refs/heads/$BRANCH ]];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
The structure of the remote server is:
/www/[sitename]_571/ -> private -> [sitename].git
-> hooks
-> public -> website files + .git
What's the least destructive way to get git back on the live site, so we can start making deployments again?
Thanks!