简体   繁体   中英

Remove development files from production using git ignore

My git repository is having development and production files and i only want production files to be pulled in the server.

Is there anyway to exclude certain files which is in git repository during code pull?

Can we add those files in gitignore and just remove the files from production server alone?

Is there anyway to exclude certain files which is in git repository during code pull?

No. Git pull s operate on commits, not files.

Can we add those files in gitignore and just remove the files from production server alone?

No. Git's ignore system only prevents files from being tracked. Once a file is in your repository, adding it to .gitignore will do nothing.

Depending on what you mean by "production files", they can likely be generated by a build tool. Track only your development files in Git, push to your server, and build minified / compilied / etc. files automatically with Jenkins or a post-receive hook or something similar.

Your push target should not be where your production files need to go, and can likely be a bare repository. Your built files can get deployed to the production location as soon as the build is done.

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