# Folding commits together

4 messages from 2010-09-22 to 2010-09-22. Participants: Maaartin, Matthieu Moy, Jay Soffian.
Thread: https://gitlist.dev/t/25197

## Maaartin, 2010-09-22 10:51

Subject: Folding commits together
Message-ID: <loom.20100922T123419-101@post.gmane.org>
URL: https://gitlist.dev/e/loom.20100922T123419-101%40post.gmane.org

```
I've made a couple of trivial commits I'd like to fold into a single commit now. 
In the manpage of git-rebase I saw a recipe how to do it using rebase -i and it 
seemed quite trivial, but it doesn't work for me. I'm in a clean state on branch 
master and want fold the last 3 commits into one - this is probably the most 
trivial use case. Whatever I try I get an empty .git/rebase-merge/git-rebase-
todo, so I can't get to the point of using <<If you want to fold two or more 
commits into one, replace the command "pick" for the second and subsequent 
commits with "squash" or "fixup".>>

```

## Matthieu Moy, 2010-09-22 11:13

Subject: Re: Folding commits together
Message-ID: <vpqsk12rpz4.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqsk12rpz4.fsf%40bauges.imag.fr
In-Reply-To: <loom.20100922T123419-101@post.gmane.org>

```
Maaartin <grajcar1@seznam.cz> writes:

> I've made a couple of trivial commits I'd like to fold into a single commit now. 
> In the manpage of git-rebase I saw a recipe how to do it using rebase -i and it 
> seemed quite trivial, but it doesn't work for me. I'm in a clean state on branch 
> master and want fold the last 3 commits into one - this is probably the most 
> trivial use case. Whatever I try I get an empty .git/rebase-merge/git-rebase-
> todo, so I can't get to the point of using <<If you want to fold two or more 
> commits into one, replace the command "pick" for the second and subsequent 
> commits with "squash" or "fixup".>>

Which exact command did you type? Something like this should do it:

git rebase -i HEAD~3

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Maaartin, 2010-09-22 11:33

Subject: Re: Folding commits together
Message-ID: <loom.20100922T132318-104@post.gmane.org>
URL: https://gitlist.dev/e/loom.20100922T132318-104%40post.gmane.org
In-Reply-To: <vpqsk12rpz4.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr> writes:

> Which exact command did you type? Something like this should do it:
> 
> git rebase -i HEAD~3

I've tried nearly everything, starting with

git rebase -i d8e3842

which should be the just the same as HEAD~3. I retract the question, my editor 
keeps opening a wrong file, which I've just spotted by accident. The problem was 
caused by a git-cygwin-emacsclient-emacs interaction, rebase works nicely.

```

## Jay Soffian, 2010-09-22 19:25

Subject: Re: Folding commits together
Message-ID: <AANLkTikqmJrLoF8tvpUoE7gfPOtHkFr0VMH0oqzdxani@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikqmJrLoF8tvpUoE7gfPOtHkFr0VMH0oqzdxani%40mail.gmail.com
In-Reply-To: <loom.20100922T132318-104@post.gmane.org>

```
On Wed, Sep 22, 2010 at 7:33 AM, Maaartin <grajcar1@seznam.cz> wrote:
> Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr> writes:
>
>> Which exact command did you type? Something like this should do it:
>>
>> git rebase -i HEAD~3
>
> I've tried nearly everything, starting with
>
> git rebase -i d8e3842
>
> which should be the just the same as HEAD~3. I retract the question, my editor
> keeps opening a wrong file, which I've just spotted by accident. The problem was
> caused by a git-cygwin-emacsclient-emacs interaction, rebase works nicely.

Another way to do this if it's the top-most commits is:

$ git reset --soft HEAD~3
$ git commit --amend

j.

```
