git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Matthias Fechner <idefix@fechner.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Undo a commit that is already pushed to central server and merged to several branches
Date: Wed, 7 Dec 2011 20:12:22 +0530	[thread overview]
Message-ID: <CALkWK0k46HnWTHx3iYuWFUegTgZhAMShx9MT2E83QCmxrvZOxg@mail.gmail.com> (raw)
In-Reply-To: <4EDF74EC.6090504@fechner.net>

Hi Matthias,

Matthias Fechner wrote:
> [...]
> I continued to work then on different branches and merged the bad master
> branch to all my other branches.
> [...]
>
> What I would like to do is move this bogus commit into a different branch
> and remove all changes from this bogus commit from every branch.

If I understand correctly, each of your branches looks like*:

o  <--- HEAD of branch; merge commit referencing bogus commit
| \
o  \   <--- This is where you want to move the HEAD to
|   \
o    o  <-- Bogus commit from master branch
|
o
|
o  <-- Branch born

Assuming that you actually want to rewrite the history, the situation
calls for a git-reset(1).  Just "git reset --hard HEAD~1" on each of
your branches (Caution: first understand what it does!) and you'll
rewind the HEAD to "undo" the bad merge.  After that you can just "git
push +foo:foo" to overwrite the foo branch on your server.  If you
don't want to rewrite anything and simply commit the inverse of the
bad commit, see git-revert(1).

* If you're having difficulty understanding the diagram, please read:
http://eagain.net/articles/git-for-computer-scientists/

Cheers.

-- Ram

  reply	other threads:[~2011-12-07 14:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 14:15 Undo a commit that is already pushed to central server and merged to several branches Matthias Fechner
2011-12-07 14:42 ` Ramkumar Ramachandra [this message]
2011-12-07 15:35   ` Matthias Fechner
2011-12-07 16:01     ` Ramkumar Ramachandra
2011-12-07 16:01     ` Johan Herland
2011-12-08  9:46       ` Matthias Fechner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALkWK0k46HnWTHx3iYuWFUegTgZhAMShx9MT2E83QCmxrvZOxg@mail.gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=idefix@fechner.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).