简体   繁体   中英

SSH git — How to pull a folder from repo, but not delete other directories & files on deployment server

I asked this question on wordpress.stackexchange, and was told it should be asked here.

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?

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 would say that under normal circumstances , what you are worried about shouldn't be possible. The reason is, typically your code repository should be completely separate from the hosted code on your web server. Generally you wouldn't even need a copy of the repo on the public web server at all. Instead you would deploy your code to the web server from another machine that has the code repo on it.

However, in the case that you want to have the repo on your web server, then perhaps it should be in an entirely separate location from the public web code, and then you can deploy it from the repo to the proper public web folders on the same server.

Note the deploy process is what generates the artifacts, and preferably copies only the required artifacts to the served web location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM