Tuesday, 15 April 2025

Move a Git & Maven project as module to a parent project

Maven 3.9.9
Git 2.49.0.window.1

First go to the parent folder in Git Bash and add a git subtree:

git subtree add -P dir-name git-repo revision

dir-name:    name of the module
git-repo:      The git-url from the project you want to move. In Bitbucket you find this in repository settings. example: https://git.mycompany.com/git/scm/clients/mycompany-webservice-client.git
revision:      for me this was always HEAD

This adds the project to the parent project.

Next steps:
- in the module pom set the parent and delete the own version and maybe SCM tag
- in the parent add the module as module (and maybe as dependency with the project.version version, if you want to use the parent as bom (bill of materials))

Sources:
How to Move a Git Repository into a Sub-Folder of Another Repository



No comments:

Post a Comment