将单片应用程序转换为基于微服务的体系结构并保持GIT历史记录(Turing a monolithic application into a Microservice based architecture and keeping the GIT history)

我打算将单片应用程序拆分为基于微服务的架构,但我希望保留GIT历史记录。

monolit应分为三个微服务。

我的第一种方法是,复制GIT存储库三次,并从新的微服务中删除所有非域特定部分,这应该保持git历史的大部分内容。 但是,如果这是保持版本控制历史记录的最佳方式,那么我并不感到害羞。

I'm planning to split a monolithic application into a micro service based architecture, but I want to keep the GIT history.

The monolit should be split into three micro services.

My first approach would be, copying the GIT Repository three times and removing all non domain specific parts from the new micro service which should keep the most parts of the git history alive. But I am not shure if this is the best way keeping the version control history.

最满意答案

您可以使用带有--subdirectory-filter选项的git filter-branch来过滤存储库的子目录,从而使存储库包含子目录作为根目录。 这里的步骤5对此进行了描述, 此处的文档也可能有所帮助。 您必须将您的存储库克隆三次,并在每个存储库中为项目的不同部分运行filter-branch 。

由于(使用--subdirectory-filter )只能以这种方式处理子目录,因此您可能必须重新安排存储库。 然而,优先于删除其他部分的优点是,通过使用filter-branch您将只预先设置与存储库的实际内容有关的历史记录,并且没有过滤掉部件的任何历史记录。

You can use git filter-branch with the --subdirectory-filter option to filter a subdirectory of your repository and thus make the repository contain the subfolder as root directory. This is described in step 5 here, documentation here might also help. You would have to clone your repository three times and run filter-branch in each of those for a different part of your project.

Since (with said --subdirectory-filter) only subdirectories can be treated this way, you may have to rearrange your repository before. The advantage over the naive deletion of other parts is, however, that by using filter-branch you will only preseve history that concerns the actual content of your repository, and do not have any history of the parts filtered out.

更多推荐