I flubbed up my history and want to do some changes to it. Problem is, I have a commit with two unrelated changes, and this commit is surrounded by some other changes in my
To split a commit and add the new commit before this one, and save the author date of , — the steps are following:
Edit the commit before
git rebase -i ^^
NB: perhaps it will be also needed to edit as well.
Cherry pick into the index
git cherry-pick -n
Interactively reset unneeded changes from the index and reset the working tree
git reset -p && git checkout-index -f -a
As alternative, just stash unneeded changes interactively: git stash push -p -m "tmp other changes"
Make other changes (if any) and create the new commit
git commit -m "upd something" .
Optionally, repeat the items 2-4 to add more intermediate commits.
Continue rebasing
git rebase --continue