| Next | git-rebase: why and how | 4 |
Suppose I am making some changes to my topic branch topic
After three commits, I realize I don't have topic checked out
I have main checked out
CRAP

I can use git-rebase to copy the commits to the right branch
git rebase topic

Then I put main back where it is supposed to go
git checkout topic
git reset --hard main
git checkout main
git reset --hard HEAD~5

| Next | ![]() |