I have a large codebase which I am evaluating a strategy to split certain sections off into smaller repositories. Using git subtree split, I am able to separate out the directories I want & the commit history seems intact.
That being said, assuming I move forward with this approach, what will happen to my old pull requests (which included code from the detached directories) in Github?
Will they still show references to the old code or will the changes only reference the code that is still in the original codebase?
Thanks for the help.
The new created repo from git subtree split
will only contains the commits that you make changes in the specified directories.
Assume the original git repo file structure as below:
Root
|___ file1
|___ file2
|___ subfolder/
|___ file3
|___ file4
And the original commit history as:
* 8cb09fb (HEAD -> master) Merge branch 'dev' into matser
|\
| * e1e054c (dev) change file2 for fourth time merge
* | 6e8ee57 change file3 for fourth time merge
* | ebdfb0b Merge branch 'dev' into master
|\ \
| |/
| * 5d93766 change file2 for thrid time merge
* | b95668a change file1 for thrid time merge
* | 09ca222 Merge branch 'dev' into matser
|\ \
| |/
| * d3dc890 change file3 for second time merge
* | 5818123 change file1 for second time merge
* | cb39f04 Merge branch 'dev' into master
|\ \
| |/
| * 4dc4aaa change file3 and file4 on dev branch
* | fef775c change file3 and file4 on master branch
|/
* d8d81e6 add subfolder and it’s files
* 5446ea3 change file1
If you use git subtree split
to split the subfolder
to a new git repo, then only the commits which changed the subfolder
(file3
and file4
) will show in the new repo commit history. The new repo commit history as below:
* 60a7f3e (master) change file3 for fourth time merge
* 954b730 Merge branch 'dev' into master
|\
| * b4b8d92 change file3 for second time merge
* | 35f7754 Merge branch 'dev' into matser
|\ \
| |/
| * fde1de3 change file3 and file4 on master branch
* | d4795a8 change file3 and file4 on master branch
|/
* cd367a2 add subfolder and it’s files
As you can see in the original repo:
5446ea
, it only changed file1
(out of subfolder
directory), so the commit won’t show in the new repo.5818123
need to merge for second time, since it also only changed file1
, the commit won’t show in the new repo.b95668a
, 5d93766
and ebdfb0b
) for third time merge, all of them are not changed the subfolder
, so they won’t show in the new repo.e1e054c
, it only changed file2
on dev
branch, so it won’t show in the new repo.8cb09fb
, it keep the subfolder
(file3
and file4
) as the same version with it’s first parent commit 6e8ee57
(not changed subfolder) on master
branch, so the commit also won’t show in new repo.