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:
- For the first commit
5446ea
, it only changed file1
(out of subfolder
directory), so the commit won’t show in the new repo.
- For the commit
5818123
need to merge for second time, since it also only changed file1
, the commit won’t show in the new repo.
- For the commits (
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.
- For the commit
e1e054c
, it only changed file2
on dev
branch, so it won’t show in the new repo.
- For the fourth merged commit
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.