by glandium · 10y ago · 0 comments
Other ways to do it (that don't require to retype the commit message): - rebase onto the correct branch:
git branch foo
git reset --hard HEAD~
git rebase --onto name-of-the-correct-branch HEAD foo
git checkout name-of-the-correct-branch
git merge foo
git branch -D foo
- cherry-pick git reset --hard HEAD~
git checkout name-of-the-correct-branch
git cherry-pick name-of-the-branch-you-mistakenly-committed-to@{1} (or git cherry-pick HEAD@{2})
> Oh shit, I tried to run a diff but nothing happened?!You probably want to know `git diff HEAD` too.
Edit: formatting.
git checkout -b actual-branch
git branch -f master origin/master git branch name-of-the-correct-branch
git reset --hard HEAD~
git checkout name-of-the-correct-branch