Guido Krömer
Guido Krömer

Reputation: 487

Turing a monolithic application into a Microservice based architecture and keeping the GIT history

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.

Upvotes: 0

Views: 116

Answers (1)

kowsky
kowsky

Reputation: 14499

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.

Upvotes: 1

Related Questions