2

There are numerous tutorials on how to split a large git repository (LargeRepo) into smaller repositories (SmallRepoA, SmallRepoB) and preserve commits. I'd like to do that with the added requirement that each SmallRepo inherits only those branches and branch commits that are relevant to the files in the SmallRepo.

For each SmallRepo:

  1. Don't maintain a branch if the branch has no affect on the files in SmallRepo
  2. For the remaining branches, remove commits that have no affect on the files in SmallRepo.

Effectively, I'm trying to get the end result to micmic what the world would look like if I had the individual SmallRepos to begin with.

Here's an example:

Lets say LargeRepo looks like this:

LargeRepo
|---- Folder1
|---- Folder2
|---- Folder3

And I want to split into three SmallRepos, one for each high-level Folder.

Folder1
Folder2
Folder3

Lets say LargeRepo had Branch1 and Branch23. Branch1 made changes to files in Folder1, Branch23 made changes to files in Folder2 and Folder3.

The branch view would look like this:

Folder1
|----> Branch1 (all commits)

Folder2
|-----> Branch23 (only commits affecting files in Folder2)

Folder3
|------> Branch23 (only commits affecting files in Folder3)

Ideally the solution can be implemented with the git command-line on Windows and would not involve BASH.

4

1 回答 1

1

这种拆分回购的通用解决方案也适用于取消范围分支: https ://stackoverflow.com/a/17864475/356790

出于某种原因,它不适用于我在本地创建的存储库,但适用于我从 GitHub 克隆的存储库。

于 2013-11-17T00:07:51.277 回答