If I set up a post-recieve hook in git like
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
Will that delete files that are on the server but not on my local git repo?
If it will, is there any way to stop that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends if the files will be deleted depending if they already existed in the repository prior to the checkout.
If the files that are on the server (/var/www/www.example.org) are tracked in the repo on the server but the new checkout includes a change that removed them then they will be removed on the server side.
If the files that are on the server are NOT tracked in the repo on the server then they will stay. Since Git doesn’t know about them Git won’t remove them.
To tell if they are tracked on the server you can do
git status <file in question>. If it says:Then you know that a checkout would not remove .
Just take note if later exists in a new checkout than the next checkout which removes would remove it.