0

I'm new to thi workflow, so excuse this if it's a dumb question. I set up a post-receive hook for my wordpress website. It's a great way to make deployments - although it overwrites the wp-config.php file with each push. .gitignore is set to ignore everything but wp-content in the root directory, so I don't know how wp-config.php could be getting overwritten.

I suspect the issue is in my post-receive file:

#!/bin/bash
TRAGET="/www/my_site/public"
GIT_DIR="/www/my_site/private/my_site.git"

while read oldrev newrev ref
       # 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=$TRAGET --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

But either way, here's the .gitignore

# ignore everything in the root except the "wp-content" directory.
!wp-content/

# ignore everything in the "wp-content" directory, except:
# "mu-plugins", "plugins", "themes" directory
wp-content/*
!wp-content/mu-plugins/
!wp-content/plugins/
!wp-content/themes/

# ignore node dependency directories
node_modules/

# ignore log files and databases
*.log
*.sql
*.sqlite

Thank you for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.