I have a big git repo and I want to split that into 2. I am able to do this using "git filter-branch" or "git subtree split" but both methods are creating completely new commits-ids (SHAs). I know we are rewriting history and it will change commit-ids.
But my requirement needs to have same commit-ids even after splitting repos. Is it possible?
Example:
Have a git repo foo-bar.git with below commits
*foo-bar.git*
1fd3dsg refs #1 change-1 to foo
4sad2as refs #2 change-1 to bar
3edsads refs #3 change-2 to foo
5adsggh refs #4 change-2 to bar
Now we split repo foo-bar.git into foo.git and bar.git. Now foo.git will get all commits made for foo and bar.git will get all commits made for bar, but their commit-ids have changed.
What I got:
*foo.git*
s43dfsa refs #1 change-1 to foo
a234s2f refs #3 change-2 to foo
*bar.git*
1s3ds3q refs #2 change-1 to bar
3re2ef2s refs #4 change-2 to bar
What I am expecting.
*foo.git*
1fd3dsg refs #1 change-1 to foo
3edsads refs #3 change-2 to foo
*bar.git*
4sad2as refs #2 change-1 to bar
5adsggh refs #4 change-2 to bar
Changing commit ids is inevitable. These are based on the changes in each commit, the commit message, and the parent commit id.
Because that parent commit id will change when you rearrange the single commits, the commit ids cannot stay the same.