简体   繁体   English

GIT工作流程开发(所有文件)与生产(部分文件)

[英]GIT workflow development (all files) vs production (partial files)

Setup: 设定:

1 GIT repository which contains client/server/shared code, currently on 1 branch. 1个GIT存储库,其中包含客户机/服务器/共享代码,当前位于1个分支上。

Build process: 构建过程:

  • The client is a web-based application and needs to be minimized/bundled/etc, which results in one file 客户端是基于Web的应用程序,需要最小化/打包/等,从而生成一个文件
  • The server remains the same for now, although it might be bundled later on 服务器暂时保持不变,尽管稍后可能会捆绑在一起

Problem: 问题:

I do not want all files to be on my production server, just the bundled version of the client and the server folder . 我不希望所有文件都在我的生产服务器上,而只是客户机和服务器文件夹的捆绑版本 If I would pull the master branch in, I get all files and not just the bundled version. 如果我将master分支拉进去,我将获得所有文件,而不仅仅是捆绑版本。

Solution: 解:

??? ??? - How do I have to handle this? -我该如何处理? Create additional repository, create multiple branches? 创建其他存储库,创建多个分支? How is this typically done? 通常如何完成?

Typically you would like to separate your Source Control, build process and deployable artifacts. 通常,您希望将源代码管理,构建过程和可部署工件分开。 Git is primarily for Source Control, the accepted practice is to only have source code in it. Git主要用于源代码控制,公认的做法是仅包含源代码。

Then you would have it built with some build tool (Jenkins, bamboo etc.) Then you can either use the build result from the build tool, or if you prefer use a version control for your artifacts like Nexus or artifactory. 然后,您将使用某些构建工具(Jenkins,Bamboo等)对其进行构建。然后,您可以使用构建工具中的构建结果,或者如果您更喜欢对Nexus或工件等工件使用版本控制。

This may sound complicated, but does avoid a lot of problems in future. 这听起来可能很复杂,但是将来确实可以避免很多问题。

You can use .gitattributes (5) export-ignore directive to select files which are in your version control, but you don't need on production. 您可以使用.gitattributes (5) export-ignore指令来选择版本控制中的文件,但是在生产中不需要。

If you use a deployment system like Capistrano 3 it will actually use git-archive (1) . 如果您使用Capistrano 3这样的部署系统,它将实际上使用git-archive (1) This command would create an archive to be deployed in the release folder and it will abide the export-ignore rules in your .gitattributes file. 此命令将创建要在发布文件夹中部署的存档,并且将遵守.gitattributes文件中export-ignore规则。


For your client file, you can bundle the file locally or on the machine where you deploy and then rsync it or upload it any other way to the release folder on the production machine before activating the new release. 对于客户端文件,您可以在本地或在您部署的计算机上捆绑文件,然后将其重新rsync或以任何其他方式将其上传到生产计算机上的发布文件夹,然后再激活新版本。

I can also recommend that you actually deploy your client file to a CDN and the server would just serve an HTML page with a versioned client from your CDN. 我还可以建议您实际将客户端文件部署到CDN上,并且服务器将只提供CDN中带有版本控制客户端的HTML页面。

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

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