Splitting a repository
Sometimes, a project tracked with Git is not one logical project, but consists of several projects. This may be fully intentional and there is nothing wrong with that, but there can also be cases where projects tracked in the same Git repository really should belong to two different repositories. You can imagine a project where the code base grows and, at some point in time, one of the subprojects could have value as an independent project. This can be achieved by splitting the subfolders and/or files that contain the project that should have its own repository with the full history of commits touching the files and/or folders.
Getting ready
In this example, we'll use the JGit repository, so we'll have some history to filter through. The subfolders we split into are not really projects, but serve well as an example for this exercise.
- First, clone the JGit repository and create local branches of the remote ones using the following command:
$ git clone https://git.eclipse...