Note that there are some explanatory texts on larger screens.

plurals
  1. POUndo a particular commit in Git that's been pushed to remote repos
    primarykey
    data
    text
    <p>What is the simplest way to undo a particular commit that is:</p> <ul> <li>not in the head or HEAD</li> <li>Has been pushed to the remote.</li> </ul> <p>Because if it is not the latest commit, </p> <pre><code>git reset HEAD </code></pre> <p>doesn't work. And because it has been pushed to a remote,</p> <pre><code>git rebase -i </code></pre> <p>and</p> <pre><code>git rebase --onto </code></pre> <p>will cause some problem in the remotes. </p> <p>More so, I don't want to modify the history really. If there was bad code, it was there in the history and can be seen. I just want it out in the working copy, and I don't mind a reverse merge commit.</p> <p>In other words, what is the <a href="http://en.wikipedia.org/wiki/Git_%28software%29" rel="noreferrer">Git</a> equivalent of the following svn commands:</p> <pre><code>svn merge -r 303:295 http://svn.example.com/repos/calc/trunk </code></pre> <p>which removes all changes from 295 to 302 by reverse merging all changes in those revisions, as a new commit.</p> <pre><code>svn merge -c -302 ^/trunk </code></pre> <p>which undoes the 302 commit, of course by adding another commit that reverse merges the changes from that respective commit.</p> <p>I thought it should be a fairly simple operation in Git and a fairly common use case. What else is the point of atomic commits? </p> <p>We have staging <a href="http://en.wikipedia.org/wiki/Git_%28software%29#Stash" rel="noreferrer">stashing</a> and all to ensure the commits are perfectly atomic, shouldn't you be able to undo one or more of those atomic commits easily?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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