* How to split a big commit
@ 2011-04-04 11:52 Nguyen Thai Ngoc Duy
2011-04-04 13:00 ` Ramkumar Ramachandra
2011-04-05 0:08 ` Jonathan Nieder
0 siblings, 2 replies; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-04-04 11:52 UTC (permalink / raw)
To: Git Mailing List
After a lot of small commits and a few mixed up large commits, it was
too messy that I merged them all into one big commit then started
spliting it into smaller, reasonable patches. Just wonder if anybody
else faces the same thing and how they deal with it. I used "git reset
--soft <big commit>^" and "git add -N" because there were new files,
but it was clumsy.
--
Duy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to split a big commit
2011-04-04 11:52 How to split a big commit Nguyen Thai Ngoc Duy
@ 2011-04-04 13:00 ` Ramkumar Ramachandra
2011-04-04 14:25 ` Nguyen Thai Ngoc Duy
2011-04-05 0:08 ` Jonathan Nieder
1 sibling, 1 reply; 6+ messages in thread
From: Ramkumar Ramachandra @ 2011-04-04 13:00 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: Git Mailing List
Hi Nguyen,
Nguyen Thai Ngoc Duy writes:
> After a lot of small commits and a few mixed up large commits, it was
> too messy that I merged them all into one big commit then started
> spliting it into smaller, reasonable patches. Just wonder if anybody
> else faces the same thing and how they deal with it. I used "git reset
> --soft <big commit>^" and "git add -N" because there were new files,
> but it was clumsy.
To split a big commit, I simply reverse-diff-apply the changes that I
don't want in the big commit, and I stage all changes. Then, I again
reverse-diff-apply all the staged changes, and keep that in the
unstaged portion. Your repository should look like this now:
commit bigcommit
diff --git a/bigfile b/bigfile
+Desirable change
+Undesirable change
Staged changes:
diff --git a/bigfile b/bigfile
-Undesirable change
Unstaged changes:
diff --git a/bigfile b/bigfile
+Undesirable change
Now simply 'commit --amend' to remove the undesirable change from the
bigcommit, and commit the unstaged changes to produce a new
commit. Final result:
commit bigcommit
diff --git a/bigfile b/bigfile
+Desirable change
commit newcommit
diff --git a/bigfile b/bigfile
+Undesirable change
I can afford to do this kind of jugglery very easily because I use
Magit with Emacs. After highlighting the relevant portions,
reverse-diff-apply is one keystroke :) But yes, you're probably right-
there should be an easier way to do this. Maybe a 'git split' that
allows you to interactively select the portions of an existing commit
that you'd like to exclude from the commit and turn into a new commit?
Hope that helps.
-- Ram
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to split a big commit
2011-04-04 13:00 ` Ramkumar Ramachandra
@ 2011-04-04 14:25 ` Nguyen Thai Ngoc Duy
0 siblings, 0 replies; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-04-04 14:25 UTC (permalink / raw)
To: Ramkumar Ramachandra; +Cc: Git Mailing List
On Mon, Apr 4, 2011 at 8:00 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> To split a big commit, I simply reverse-diff-apply the changes that I
> don't want in the big commit, and I stage all changes. Then, I again
> reverse-diff-apply all the staged changes, and keep that in the
> unstaged portion.
Won't work for me. The reverse part would be way larger than the to-commit part.
> ...
> I can afford to do this kind of jugglery very easily because I use
> Magit with Emacs. After highlighting the relevant portions,
> reverse-diff-apply is one keystroke :)
Hmm.. interesting. Never got around to actually use magit. I may have
a good reason now.
> But yes, you're probably right-
> there should be an easier way to do this. Maybe a 'git split' that
> allows you to interactively select the portions of an existing commit
> that you'd like to exclude from the commit and turn into a new commit?
Hmm..yeah something like grep for chunks, then automatically splitting
those chunks out would be nice.
I have another use for such a tool too. When .po files are
automatically updated by intltool (gnome translation helper tool),
comment lines are all changed because they contain source line and
those line likely change. With this tool I can filter out comment-only
changes.
Thanks for the idea.
--
Duy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to split a big commit
2011-04-04 11:52 How to split a big commit Nguyen Thai Ngoc Duy
2011-04-04 13:00 ` Ramkumar Ramachandra
@ 2011-04-05 0:08 ` Jonathan Nieder
2011-04-05 2:31 ` Lasse Makholm
2011-04-05 2:52 ` Nguyen Thai Ngoc Duy
1 sibling, 2 replies; 6+ messages in thread
From: Jonathan Nieder @ 2011-04-05 0:08 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: Git Mailing List, Ramkumar Ramachandra
Hi Duy,
Nguyen Thai Ngoc Duy wrote:
> After a lot of small commits and a few mixed up large commits, it was
> too messy that I merged them all into one big commit then started
> spliting it into smaller, reasonable patches. Just wonder if anybody
> else faces the same thing and how they deal with it. I used "git reset
> --soft <big commit>^" and "git add -N" because there were new files,
> but it was clumsy.
I tend to do "git reset HEAD^ -- ." and then "git add -N ." and
"git add -p", for what it's worth.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to split a big commit
2011-04-05 0:08 ` Jonathan Nieder
@ 2011-04-05 2:31 ` Lasse Makholm
2011-04-05 2:52 ` Nguyen Thai Ngoc Duy
1 sibling, 0 replies; 6+ messages in thread
From: Lasse Makholm @ 2011-04-05 2:31 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Nguyen Thai Ngoc Duy, Git Mailing List, Ramkumar Ramachandra
On 5 April 2011 02:08, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Duy,
>
> Nguyen Thai Ngoc Duy wrote:
>
>> After a lot of small commits and a few mixed up large commits, it was
>> too messy that I merged them all into one big commit then started
>> spliting it into smaller, reasonable patches. Just wonder if anybody
>> else faces the same thing and how they deal with it. I used "git reset
>> --soft <big commit>^" and "git add -N" because there were new files,
>> but it was clumsy.
>
> I tend to do "git reset HEAD^ -- ." and then "git add -N ." and
> "git add -p", for what it's worth.
In addition, after you've added some hunks, use git stash to stow away
all the other changes to test each new commit seperately.
/Lasse
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How to split a big commit
2011-04-05 0:08 ` Jonathan Nieder
2011-04-05 2:31 ` Lasse Makholm
@ 2011-04-05 2:52 ` Nguyen Thai Ngoc Duy
1 sibling, 0 replies; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-04-05 2:52 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Git Mailing List, Ramkumar Ramachandra
On Tue, Apr 5, 2011 at 7:08 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Duy,
>
> Nguyen Thai Ngoc Duy wrote:
>
>> After a lot of small commits and a few mixed up large commits, it was
>> too messy that I merged them all into one big commit then started
>> spliting it into smaller, reasonable patches. Just wonder if anybody
>> else faces the same thing and how they deal with it. I used "git reset
>> --soft <big commit>^" and "git add -N" because there were new files,
>> but it was clumsy.
>
> I tend to do "git reset HEAD^ -- ." and then "git add -N ." and
> "git add -p", for what it's worth.
But you would need to undo "git add -N" for those files you don't want in yet?
--
Duy
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-05 2:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-04 11:52 How to split a big commit Nguyen Thai Ngoc Duy
2011-04-04 13:00 ` Ramkumar Ramachandra
2011-04-04 14:25 ` Nguyen Thai Ngoc Duy
2011-04-05 0:08 ` Jonathan Nieder
2011-04-05 2:31 ` Lasse Makholm
2011-04-05 2:52 ` Nguyen Thai Ngoc Duy
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).