git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Dirk Süsserott" <newsletter@dirk.my1.cc>
To: Peter Krefting <peter@softwolves.pp.se>
Cc: Gergely Buday <gbuday@gmail.com>, git@vger.kernel.org
Subject: Re: removing a commit from a branch
Date: Wed, 04 May 2011 19:53:36 +0200	[thread overview]
Message-ID: <4DC192A0.6010808@dirk.my1.cc> (raw)
In-Reply-To: <alpine.DEB.2.00.1105041014480.16939@ds9.cixit.se>

Am 04.05.2011 11:17 schrieb Peter Krefting:
> Gergely Buday:
>
>> I have a problematic commit in a series of commits on a branch. It
>> contains adding a large binary file, which I would like to avoid to
>> push to our main repository. How can I remove that from the series of
>> commits? A command-line solution, please, if possible.
>
> If the branch is simple (no merges and such), I'd use "git rebase
> --interactive branchpoint" (where "branchpoint" is where the branch is
> rooted), or "git rebase --interactive problematic^" (where "problematic"
> is the commit you want to edit, note the trailing "^" to start from its
> parent commit).
>
> Then change the "pick" for the problematic commit to "edit", run the
> rebase, fix up the commit by using "git rm" and "git commit --amend"
> when it pauses, and then let it finish using "git rebase --continue".
>
> "git --help rebase" for more information.
>

If your "problematic" commit contains only that "large file" and nothing 
else, then you'd probably like to remove the whole commit instead of 
editing it (as Peter described). Just do:

$ git rebase --interactive problematic^

Again, notice the ^ after "problematic"

An editor pops up with the history since problematic's parent, i.e. 
"problematic" is the first item in the list. Simply delete the line with 
the "problematic" commit. It should be the first line. Save the file, 
exit the editor. That's it.

     Dirk

  reply	other threads:[~2011-05-04 17:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-04  8:35 removing a commit from a branch Gergely Buday
2011-05-04  8:45 ` Jeff King
2011-05-04  8:55   ` Gergely Buday
2011-05-04  9:17 ` Peter Krefting
2011-05-04 17:53   ` Dirk Süsserott [this message]
2011-05-04 19:12     ` Sorry, completely off-topic. I've a mailer problem (was: Re: removing a commit from a branch) Dirk Süsserott
2011-05-04 21:28       ` Øyvind A. Holm
     [not found]       ` <4DC1B103.90007@cisco.com>
2011-05-05 18:59         ` Sorry, completely off-topic. I've a mailer problem Dirk Süsserott

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=4DC192A0.6010808@dirk.my1.cc \
    --to=newsletter@dirk.my1.cc \
    --cc=gbuday@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peter@softwolves.pp.se \
    /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).