Fixing a mangled master branch in fork
<p>I was working on a pull request for an open source project, but I accidentally committed my changes to my local <code>master</code> branch. Without thinking it over hard enough, I just went ahead and pushed it to my origin and submitted my master branch as a PR. Then I later pulled the upstream master into my master so I could fix merge conflicts to keep my PR up to date. Since then, more commits have been made to upstream.</p>

<p>So now I have:</p>

<pre><code>upstream master: A - B - C ... H - I - J

my fork master:  A - B - X - Y
</code></pre>

<p>Where X was the first version of my PR, and Y is a merge of C-H onto X.</p>

<p>So now my fork is in quite a tangle. I can't work on unrelated PRs without starting a branch before B and then pulling upstream master into that branch each time. And if my original PR is rejected or takes a year to get feedback on, I'll be stuck in this state indefinitely.</p>

<p>Are there any options for fixing this? Do I have to nuke my PR and my X and Y commits and redo them manually (and if so, how)? Or can I salvage my PR somehow and get my master branch back in sync with upstream?</p>