简体   繁体   English

使用gitignore从生产中删除开发文件

[英]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. 我的git存储库中包含开发和生产文件,我只希望将生产文件拉到服务器中。

Is there anyway to exclude certain files which is in git repository during code pull? 无论如何,在代码提取期间是否要排除git存储库中的某些文件?

Can we add those files in gitignore and just remove the files from production server alone? 我们可以在gitignore中添加这些文件,而仅从生产服务器中删除这些文件吗?

Is there anyway to exclude certain files which is in git repository during code pull? 无论如何,在代码提取期间是否要排除git存储库中的某些文件?

No. Git pull s operate on commits, not files. 不行。Git pull的操作是提交,而不是文件。

Can we add those files in gitignore and just remove the files from production server alone? 我们可以在gitignore中添加这些文件,而仅从生产服务器中删除这些文件吗?

No. Git's ignore system only prevents files from being tracked. 不会。Git的ignore系统只会阻止跟踪文件。 Once a file is in your repository, adding it to .gitignore will do nothing. 一旦文件在您的存储库中,将其添加到.gitignore将不会执行任何操作。

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. 仅使用Jenkins或接收后钩子或类似工具自动跟踪Git中的开发文件, push送到服务器,并自动构建缩小/编译的等文件。

Your push target should not be where your production files need to go, and can likely be a bare repository. push目标不应位于生产文件需要存放的位置,并且可能是裸仓库。 Your built files can get deployed to the production location as soon as the build is done. 构建完成后,即可将构建的文件部署到生产位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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