I want to split the first commit in my git repository, but I cannot use rebase to do this because a parent node is required. I found Edit the root commit in Git? useful for modifying the first commit, but not splitting it. How can I split it?
Share
You can just follow exactly the same process in the question you’ve linked to, but after checking out the root commit you can use
git commit --amendto modify the original commit and thengit committo make an additional commit before continuing the with the rebase command.Depending on how you want to split the commit you can use
git rm --cachedto remove files that you want to add at the second commit before the initialgit commit --amendand edit any files that you want to look different before callinggit addon those files, again before you callgit commit --amend.After calling
git commit --amend, to make sure that you commit exactly the state of the original root commit you can call:before calling
git committo make the second commit of the split root commit.