Undo pushed merge cos I meant to rebase
- checkout (detached) the last commit before the merge commit. (I don’t know how to do it in bash yet—I use VS Code GUI)
- create new branch from it
git checkout -b <new branch name> - checkout my main branch (in this case
v4notmain(yes I was fixing this repo—turns out I don’t likenpx quartz sync, I want to commit granularly)) and reset to the last commit I still want to includegit reset --hard <the commit I want to go back to> # or usually `HEAD~2` - rebase the new branch onto the main branch
git rebase <new branch name> - force push to origin
git push --force origin v4
I’m still not sure about the reset in step 3. It might not be generally applicable. Well, I will know more next time this happens.
Rebase to main
git checkout main
git rebase <new changes branch>I need to write this down because I never remember whether it’s that or the other way around
Delete local branch
git branch -D <branch name> # -D means --delete --force
git branch -d <branch name> # will error if branch hasn't been merged