So long story short I had a remote branch I was working on (my-remote-branch) that was failing some tests in the CI. I was told to rebase to master to fix this issue.
I did the following:
git checkout master
git pull
git checkout my-remote-branch
git rebase master
git push
At that point I got an error:
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
So next I did:
git pull --set-upstream-origin my-remote-branch
git push
This kind of just created a mess. My pull request now has a massive amount of commits (all the ones from master that occurred while I was working on this branch) so the history is all messed up and there's a misleading number of changed files for the pull request. This seems more complicated than a simple revert since I can't just revert back to one commit, all the commits are intertwined from master.
Apparently what I was supposed to do was this:
git fetch origin master
git rebase -I origin/master
git push --force
Is there a way I can undo my mistake (undo the merge, remove commits from history in my branch only) so I can execute the step I was supposed to do?
How do I undo a git rebase and redo as a git merge
Revert Merge and history "undo" from git
^These questions didn't help because I can't touch master in any way (besides pulling), and can't revert to a specific commit since master's commits are intertwined with mine.