Working in branch temp, I created a new branch, temp2. I rearranged a file heavily and then did some cleanup on it. I committed.
Later it occurred to me that I'd have a clearer history if I had done the rearrangement, committed, then did the cleanup, then committed.
In other words, I just want to turn this commit into two stages, two commits.
Well, I remembered the rearrangement part. So I switched to branch temp and did the rearrangement again, without the cleanup. My idea was that I could then bring the commit from temp2 onto temp.
What I have:
------ before ----- rearrangement <-- temp
\
\
\
------- rearrangement plus cleanup <-- temp2
What I want:
------ before ----- rearrangement ----- rearrangement plus cleanup <-- temp
First I tried rebasing temp2 onto temp, but I got a merge conflict. This surprised me because wasn't asking to merge anything. I thought rebasing just changed where a commit was attached. So I aborted that.
Then I tried cherrypicking "rearrangement plus cleanup" from temp2 into temp. But I still got a merge conflict. That really surprised me because I thought it was completely impossible. So I aborted that too.
I'm stuck. I don't understand what's going on here. git is not based on diffs. Commits are just snapshots. So why is there a conflict? All I'm asking to do is arrange these snapshots in a certain order. Why is that so difficult, and how can I do it?