Note that there are some explanatory texts on larger screens.

plurals
  1. POA way to revert a whole branch in a single commit
    text
    copied!<p>I need to revert a whole branch with a single commit like this:</p> <pre><code> [topic] o---o---o-------X / | [master] ---o---o---o </code></pre> <p>The commit <code>X</code> must have state like a <code>master~2</code> (the origin point of topic branch)</p> <p>My solution is:</p> <pre><code>git rev-list --reverse master..topic | while read SHA; do git revert -n ${SHA} done git commit -m "Reverted topic branch" </code></pre> <p>Is there a better (shorter) solution? </p> <p><strong>A PURPOSE OF THIS</strong></p> <p>Imagine I have a kind of almost-git-flow based repo.</p> <pre><code> [release-3] o---o---o---o / \ [fix-for-rc-3] / o---o---o / | [development] ---o---o---o </code></pre> <p>I have a <code>development</code> branch, upcoming <code>release-3</code> branch and a so-called <code>hot-fix-feature-for-rc-3</code> branch. In this branch I'm doing some ugly hack to get my release done but I don't want it in a <code>development</code> at all because more "correct" solution is already landed here but can't be applied to a <code>release-3</code> branch by some reason. So, I must do the following...</p> <pre><code> [release-3] o---o---o---o--------------------M / \ [fix-for-rc-3] / / o---o---o----------------X / \ | \[development] ---o---o---o---------------------------------D </code></pre> <p>I must merge <code>fix-for-rc-3</code> to a <code>release-3</code> (point M), then do a "revert-all-this-shit" commit (point X) and merge it do <code>development</code> (point D) so this code will never get here, even then a whole <code>release-3</code> branch is merged to <code>development</code> then release is done.</p> <p>That's why I need to revert a whole branch...</p> <p><strong>THE PROBLEM</strong></p> <p>While the root issue is solved, there are still problem getting fork point of a branch cause' if <code>topic</code> is already merged to <code>release</code> <code>merge-base</code> will fail.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload