title: How do I successfully rebase a branch onto a (github) squashed commit containing the commits it was branched off of?
body: <p>I am now unlucky enough to be stuck using github and github flow branching strategy at work. I don't like github. It has the worst implementations of pull requests I've seen, and it's CR tool makes me want to puke, but that's not the (main) problem.</p>
  <p>Our branch history currently looks like this:</p>
  <pre><code>A---B---E' main
       \
        C---D---E feature-1
                 \
                  F---G feature-2
  </code></pre>
  <p>Feature-2 was branched off of Feature-1, and feature-1 has since been merged into main, but I made what I see now was likely a mistake of using a &quot;Squash Merge&quot; in github to do so, as it was the guidance I was given both by github (ugh) and other teams.</p>
  <p>Now, we need to rebase feature-2 onto mainline, because Github otherwise includes commits C, D, and E in the changes for the feature-2 PR.</p>
  <p>When I do so, I wind up with this:</p>
  <pre><code>A---B---E'---C'---D'---E'---F---G feature-2
           \
            main
  </code></pre>
  <p>Yeah. I'm getting a conflict for every file changed in C, D and E, which are just the changes <em>already present in</em> <code>E'</code>, and then it's replaying those commits (but they're empty!) before replaying the changes from Feature-2.</p>
  <hr />
  <p>So anyway, this is a weird pain, but rebase is such a powerful tool, I'm sure there's a way to get it to look like I'd like, which is this:</p>
  <pre><code>A---B---E'---F---G feature-2
       \   \
        \    main
         C---D---E feature-1 (closed) (but not really, I'm still committing to it which will probably also come back and bite me...)
  </code></pre>
  <p>I've tried <code>git rebase --onto main feature-1 feature-2</code> per the git-rebase doc, and of course just <code>git rebase main</code>, as well as <code>git rebase --onto main</code> which just changed where my branch pointed without doing anything (I don't understand <code>--onto</code> well).</p>
  <p>Likewise if you have any tips for keeping your repo clean when using the &quot;github flow&quot; (Cause I think this likely would have happened if I'd made a merge commit as well, but maybe not?), please don't hesitate! I've been using git for years, but not github (which probably spells out where I was working), and my previous knowledge just doesn't translate.</p>