SSH git — How to pull a folder from repo, but not delete other directories & files on deployment server
I'm at a point in my git education where I've refined my .gitignore file such that when I push from my local development machine to a remote repository (which happens to be on Azure, but it could just as easily be on github), the folders and files in the repo are precisely how I want them to be. That is:
- wp-content/plugins/my-custom-plugins
- wp-content/themes/my-custom-theme
...and that's basically it. I don't want the wp-config in the mix, or any of the stock WP folders like wp-includes or wp-admin. No cache, no wp-content/uploads, etc.
Enter my question: When I SSH into the Linux web server where my website is hosted, how do I perform a git pull origin dev so that git doesn't delete my entire WordPress site, replacing it with only the folders/files in the repo?
What I've Tried:
First of all, when I perform git pull origin dev, the operation does, indeed, wipe out all of my WordPress files and leave only the pulled repo. Unacceptable, to say the least.
Since this is the development server, I can afford to play around with it and get it wrong, because I can always FTP the website back to the server. FTP'ing is very time consuming, so I don't want to get this wrong too many times. And when it comes time to do it on the production server, I cannot get it wrong even once.
I am answering the question myself, because for some reason it is attracting other comments and answers that are unrelated to the original question. I guess you can have a high rep and still have low reading comprehension.