title: Undo Published Merge and Re-Apply Original Changes Without History Rewrite
body: <p>Good evening,</p>
  <p>we've ran into the following git issues on one of our intern projects. We've got two branches, <code>main</code> and <code>feat/smth</code> and both have diverged during development. There was a pull request created from <code>feat/smth</code> to <code>main</code> which showed those conflicts. Those conflicts were resolved using the graphical tool of GitHub, basically performing a merge from <code>main</code> to <code>feat/smth</code> in order to fix the conflicts. This merge was faulty and resulted in corrupted files which were not noticed for now.</p>
  <p>Therefore, the <code>feat/smth</code> branch was merged (using GitHubs Pull Request) into <code>main</code> where the errors were found. In order to revert the changes, the students ran a <code>git revert</code> on the merge commit on main and pushed all these changes. Now, the issue is that we would like have the changes from our <code>feat/smth</code> branch and merge them &quot;again&quot; into main. Obviously, that does not work because the commits are already merged and therefore present on main.</p>
  <p>Let's assume that we <em>don't want to force push</em> because a lot of other developers already checked out the code and continued working. My first thought was to revert both merges locally using <code>git reset -m &lt;commit_sha&gt;</code> and re-perform the merge. During the merge, I've &quot;avoided&quot; the errors from the very first merge attempt. I've stashed the files, <em>pulled</em> the <code>feat/smth</code> branch and applied my stash. Using this approach, we've got the correct changes from our merge, but all other changes on the branch aren't applied anymore, as they are still reverted on the main branch. The commits of our <code>feat/smth</code> branch are already present on <code>main</code> and were <em>reverted</em>. The only change we introduce using this attempt are the correct changes from the merge.</p>
  <p>And that's where I'm basically stuck. What is a proper way in order to undo a merge pushed to main and re-apply the original changes from the branch? My first thoughts were <em>cherry picks</em>, although that might be cumbersome with a lot of commits (and might result into a lot of merge conflicts?) or to take a &quot;hard copy&quot; of the correct version of the branch and just <em>copy paste</em> them onto the main branch. However, this might result in non-wanted changes, as well. The later approach might get tricky in case that changes were made to <code>main</code> already. The author has to carefully check all the changes and distinguish between those from the <code>feat/smth</code> branch and the ones from the <code>main</code> branch. In addition, <em>copy paste</em> doesn't feel like it's the proper &quot;git way&quot;. Any ideas? I really don't know how to solve that the &quot;git way&quot;.</p>
  <p>I've made a drawing of the git history, as well for illustration purposes.</p>
  <p><a href="https://i.stack.imgur.com/rGmma.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rGmma.jpg" alt="Drawing of git history" /></a></p>
  <p>Thanks a lot! I'm curious about the approaches.</p>