# how to split a hunk

5 messages from 2009-10-28 to 2009-10-28. Participants: bill lam, Geert Bosch, Thomas Rast.
Thread: https://gitlist.dev/t/21394

## bill lam, 2009-10-28 02:21

Subject: how to split a hunk
Message-ID: <20091028022105.GE3938@debian.b2j>
URL: https://gitlist.dev/e/20091028022105.GE3938%40debian.b2j

```
There are occasions where diff of a file is

- aaaa
+ bbbb
+ cccc

I want to add lines bbbb and cccc as separated commits, but git-add -p
seem cannot further split this hunk.  Do I have no choice but to edit
it by hand and commit the bbbb and then edit the file to add back the
cccc?

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```

## Geert Bosch, 2009-10-28 03:11

Subject: Re: how to split a hunk
Message-ID: <21963906-785A-4D98-8AD8-A89ED914920C@adacore.com>
URL: https://gitlist.dev/e/21963906-785A-4D98-8AD8-A89ED914920C%40adacore.com
In-Reply-To: <20091028022105.GE3938@debian.b2j>

```

On Oct 27, 2009, at 22:21, bill lam wrote:

> There are occasions where diff of a file is
>
> - aaaa
> + bbbb
> + cccc
>
> I want to add lines bbbb and cccc as separated commits, but git-add -p
> seem cannot further split this hunk.  Do I have no choice but to edit
> it by hand and commit the bbbb and then edit the file to add back the
> cccc?
>
I like to use "git gui" for this. This allows you to pick individual
lines to commit. I really like the "git gui" interface for staging/ 
unstaging
changes and making a series of commits.

   -Geert

```

## Thomas Rast, 2009-10-28 13:06

Subject: Re: how to split a hunk
Message-ID: <200910281406.12923.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200910281406.12923.trast%40student.ethz.ch
In-Reply-To: <20091028022105.GE3938@debian.b2j>

```
bill lam wrote:
> There are occasions where diff of a file is
> 
> - aaaa
> + bbbb
> + cccc
> 
> I want to add lines bbbb and cccc as separated commits, but git-add -p
> seem cannot further split this hunk.  Do I have no choice but to edit
> it by hand and commit the bbbb and then edit the file to add back the
> cccc?

There's also the 'git add -p' [e]dit feature, which pops up the patch
in an editor.  There are instructions in that file, but in this case,
you can simply remove one of the additions.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```

## bill lam, 2009-10-28 15:16

Subject: Re: how to split a hunk
Message-ID: <20091028151631.GB3956@debian.b2j>
URL: https://gitlist.dev/e/20091028151631.GB3956%40debian.b2j
In-Reply-To: <200910281406.12923.trast@student.ethz.ch>

```
On Wed, 28 Oct 2009, Thomas Rast wrote:
> There's also the 'git add -p' [e]dit feature, which pops up the patch
> in an editor.  There are instructions in that file, but in this case,
> you can simply remove one of the additions.

Thank you for pointing out the [e], incidentally after trying it, I
also noticed and tried the add -e which belongs to a similar format.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```

## bill lam, 2009-10-28 15:26

Subject: Re: how to split a hunk
Message-ID: <20091028152651.GC3956@debian.b2j>
URL: https://gitlist.dev/e/20091028152651.GC3956%40debian.b2j
In-Reply-To: <21963906-785A-4D98-8AD8-A89ED914920C@adacore.com>

```
On Tue, 27 Oct 2009, Geert Bosch wrote:
> I like to use "git gui" for this. This allows you to pick individual
> lines to commit. I really like the "git gui" interface for staging/unstaging
> changes and making a series of commits.

Thank you suggestion. However I did not use git-gui/gitk or have tcl
installed.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3

```
