Interview Prep/Git & GitHub/Undoing changes: reset, revert, restore and reflog

How do you split a single commit into two?

AdvancedConceptUndoing changes: reset, revert, restore and reflog
Answer

Reset the commit softly and stage it in pieces, or use rebase edit.

git rebase -i HEAD~3      # mark commit as edit
git reset HEAD^           # mixed: keep changes unstaged
git add -p && git commit -m "part 1"
git add -p && git commit -m "part 2"
git rebase --continue
All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing changes: reset, revert, restore and reflog