threads / discuss / 21394

how to split a hunk

Subject: how to split a hunk

## tl;dr

5 messages between Oct 28, 2009 and Oct 28, 2009.

replies: 4people: 3as markdown or json

bill lam· Oct 28, 2009, 02:21 UTC · lore
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· Oct 28, 2009, 03:11 UTC · re: bill lam · lore

Re: how to split a hunk

On Oct 27, 2009, at 22:21, bill lam wrote:
Show 11 quoted lines
> 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
bill lam· Oct 28, 2009, 15:26 UTC · re: Geert Bosch · lore

Re: how to split a hunk

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
Thomas Rast· Oct 28, 2009, 13:06 UTC · re: bill lam · lore

Re: how to split a hunk

bill lam wrote:
Show 10 quoted lines
> 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· Oct 28, 2009, 15:16 UTC · re: Thomas Rast · lore

Re: how to split a hunk

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

← back to recent threads