I found similar questions like one below :
This question already has an answer here:
Also, I found wonderful youtube video how to split commit.
However, other sof questions or youtube didn't explain completely what need to do in order to split root commit.
Let me describe what I've : let say I have "master" branch with two commits:
- root : "init" ce0418e
- "Commit01" 8585a44
And I've another branch "anotherBranch" with three commits:
- root : "init" ce0418e
- "testCommit01" 459ca66
- "testCommit02" f9f0ba4
So I would like to split commit "init" ( it contains files: .gitignore ; README.md ; myClass )
I need that files .gitignore and README.md became the part of new "init" ( new root ) and myClass became another commit with message "myClass Splitted" and be the part of master branch.
From other sof questions I figure out that I should make the next steps :
$git rebase -i --root
in appeared new window and change from "pick" to "edit" in front of ce0418e "init" then esc then shift + ':' + 'wq'
Now I receive the message :
Stopped at ce0418e.. init
You can amend the commit now, with
git commit --amend
Once you are satisfied with your changes, run
git rebase --continue
- So I making
$git commit --amend
and I receive the windows that states:
init
Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. Date: Tue Dec 26 18:01:07 2016 +0100 interactive rebase in progress; onto 11448c4 Last command done (1 command done): edit ce0418e init Next commands to do (2 remaining commands): pick 8585a44 Commit01 You are currently editing a commit while rebasing branch 'master' on '11448c4'. Initial commit Changes to be committed: new file: .gitignore new file: README.md new file: myClass
Once again shortly, I need separate files: .gitignore and README.md from file: myClass But how ?
Obviously, I need to make some changes in this new window but what changes?
I tried to make splitting through $git status
but it seems that it doesn't work with root commit.
So my question is what should I do next ?