# removing a commit from a branch

8 messages from 2011-05-04 to 2011-05-05. Participants: Gergely Buday, Jeff King, Peter Krefting, Dirk Süsserott, Øyvind A. Holm.
Thread: https://gitlist.dev/t/27248

## Gergely Buday, 2011-05-04 08:35

Subject: removing a commit from a branch
Message-ID: <BANLkTimtpvVRU=1iCbrteyHixaWGuVKDjQ@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTimtpvVRU%3D1iCbrteyHixaWGuVKDjQ%40mail.gmail.com

```
Hi there,

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.

Cheers

- Gergely

```

## Jeff King, 2011-05-04 08:45

Subject: Re: removing a commit from a branch
Message-ID: <20110504084502.GC8512@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20110504084502.GC8512%40sigill.intra.peff.net
In-Reply-To: <BANLkTimtpvVRU=1iCbrteyHixaWGuVKDjQ@mail.gmail.com>

```
On Wed, May 04, 2011 at 10:35:08AM +0200, Gergely Buday wrote:

> 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.

Removing it will involve rewriting history, which can create headaches
for people who have built on that history (they will need to rebase
their commits on the rewritten history). But if that's OK, then the
command you want is filter-branch. See "git help filter-branch"; in
particular, the EXAMPLES section contains commands to do exactly what
you want.

-Peff

```

## Gergely Buday, 2011-05-04 08:55

Subject: Re: removing a commit from a branch
Message-ID: <BANLkTi=pVMrK8PM8s9MagN12FxMZ_=uAVw@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTi%3DpVMrK8PM8s9MagN12FxMZ_%3DuAVw%40mail.gmail.com
In-Reply-To: <20110504084502.GC8512@sigill.intra.peff.net>

```
> Removing it will involve rewriting history, which can create headaches
> for people who have built on that history (they will need to rebase
> their commits on the rewritten history).

I did not push to any other repo yet, so this should be OK.

- Gergely

```

## Peter Krefting, 2011-05-04 09:17

Subject: Re: removing a commit from a branch
Message-ID: <alpine.DEB.2.00.1105041014480.16939@ds9.cixit.se>
URL: https://gitlist.dev/e/alpine.DEB.2.00.1105041014480.16939%40ds9.cixit.se
In-Reply-To: <BANLkTimtpvVRU=1iCbrteyHixaWGuVKDjQ@mail.gmail.com>

```
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.

-- 
\\// Peter - http://www.softwolves.pp.se/

```

## Dirk Süsserott, 2011-05-04 17:53

Subject: Re: removing a commit from a branch
Message-ID: <4DC192A0.6010808@dirk.my1.cc>
URL: https://gitlist.dev/e/4DC192A0.6010808%40dirk.my1.cc
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

```

## Dirk Süsserott, 2011-05-04 19:12

Subject: Sorry, completely off-topic. I've a mailer problem (was: Re: removing a commit from a branch)
Message-ID: <4DC1A519.3070907@dirk.my1.cc>
URL: https://gitlist.dev/e/4DC1A519.3070907%40dirk.my1.cc
In-Reply-To: <4DC192A0.6010808@dirk.my1.cc>

```
Sorry, I know, this is no Thunderbird board, but I guess other people 
use this client as well.

When I write a message, it wraps at col 72 (or so). When I see my post 
in the list, it isn't wrapped at all. Only one long line per paragraph. 
That's inconvenient for the list and I'd like to avoid that. How do YOU 
do that?

I'm using Mozilla Thunderbird 3.1.10 for Windows (which is the latest, I 
think).

Again, I'm sorry about posing such an off-topic and non-git question, 
but probably someone has the same prob (or -- even better -- has had 
resolved it).

Cheers,
     Dirk

```

## Øyvind A. Holm, 2011-05-04 21:28

Subject: Re: Sorry, completely off-topic. I've a mailer problem (was: Re: removing a commit from a branch)
Message-ID: <BANLkTi=CE3aTqN+eSDwRuqvioLYtHG-z_w@mail.gmail.com>
URL: https://gitlist.dev/e/BANLkTi%3DCE3aTqN%2BeSDwRuqvioLYtHG-z_w%40mail.gmail.com
In-Reply-To: <4DC1A519.3070907@dirk.my1.cc>

```
2011/5/4 Dirk Süsserott <newsletter@dirk.my1.cc>:
> Sorry, I know, this is no Thunderbird board, but I guess other people
> use this client as well.
>
> When I write a message, it wraps at col 72 (or so). When I see my post
> in the list, it isn't wrapped at all. Only one long line per
> paragraph. That's inconvenient for the list and I'd like to avoid
> that. How do YOU do that?
>
> I'm using Mozilla Thunderbird 3.1.10 for Windows (which is the latest,
> I think).
>
> Again, I'm sorry about posing such an off-topic and non-git question,
> but probably someone has the same prob (or -- even better -- has had
> resolved it).

There is a section on how to set up Thunderbird and other mail clients
in Documentation/SubmittingPatches in the git.git repository which you
can read here:

  http://repo.or.cz/w/git.git/blob_plain/HEAD:/Documentation/SubmittingPatches

Regards,
Øyvind

```

## Dirk Süsserott, 2011-05-05 18:59

Subject: Re: Sorry, completely off-topic. I've a mailer problem
Message-ID: <4DC2F390.2040401@dirk.my1.cc>
URL: https://gitlist.dev/e/4DC2F390.2040401%40dirk.my1.cc
In-Reply-To: <4DC1B103.90007@cisco.com>

```
Am 04.05.2011 22:03 schrieb Phil Hord:
> On 05/04/2011 03:12 PM, Dirk Süsserott wrote:
>> Sorry, I know, this is no Thunderbird board, but I guess other people
>> use this client as well.
>>
>> When I write a message, it wraps at col 72 (or so). When I see my post
>> in the list, it isn't wrapped at all. Only one long line per
>> paragraph. That's inconvenient for the list and I'd like to avoid
>> that. How do YOU do that?
> 
> 
> Options > Format > Plain text only
> 
> However, your emails are being sent wrapped as you see them originally.
>   But in your email headers is this line:
> 
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> The "format=flowed" is convincing Thunderbird to unwrap your lines when
> you view them in Thunderbird. The raw text of your emails look fine.
> (In Thunderbird, examine the raw email with Ctrl-U.)
> 
> More on f=f: http://joeclark.org/ffaq.html
> 
> Phil
> 

Thank you, Phil and Øyvind,

I now configured my Thunderbird to do it right (I hope). My next post
will tell ...

Dirk

```
