* collapsing commits with rebase
@ 2009-01-08 0:08 Geoff Russell
2009-01-08 0:45 ` Johannes Schindelin
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Geoff Russell @ 2009-01-08 0:08 UTC (permalink / raw
To: git
Dear gits,
I have a series of commits:
A---B---C---D---E---F
I want to collapse B---C---D into one single commit. git rebase -i B will allow
me to do this, but I'm looking for a non-interactive incantation.
Cheers,
Geoff Russell
P.S. The context is a program that performs a single high level
operation on a repository
as a series of commits but then wants to turn it back into a single
commit without
user intervention so it subsequently looks like a single op in the history.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 0:08 collapsing commits with rebase Geoff Russell
@ 2009-01-08 0:45 ` Johannes Schindelin
2009-01-08 1:59 ` Geoff Russell
2009-01-08 2:11 ` Boyd Stephen Smith Jr.
2009-01-10 10:26 ` nadim khemir
2 siblings, 1 reply; 12+ messages in thread
From: Johannes Schindelin @ 2009-01-08 0:45 UTC (permalink / raw
To: Geoff Russell; +Cc: git
Hi,
On Thu, 8 Jan 2009, Geoff Russell wrote:
> Dear gits,
>
> I have a series of commits:
>
> A---B---C---D---E---F
>
> I want to collapse B---C---D into one single commit. git rebase -i B
> will allow me to do this, but I'm looking for a non-interactive
> incantation.
You set GIT_EDITOR to a script ;-)
Alternatively, something like this should work for you:
$ git checkout A
$ git read-tree -u -m D
$ git commit -m "My message"
$ git cherry-pick E
$ git cherry-pick F
Hth,
Dscho
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 0:45 ` Johannes Schindelin
@ 2009-01-08 1:59 ` Geoff Russell
2009-01-08 11:07 ` Johannes Schindelin
0 siblings, 1 reply; 12+ messages in thread
From: Geoff Russell @ 2009-01-08 1:59 UTC (permalink / raw
To: Johannes Schindelin; +Cc: git
On Thu, Jan 8, 2009 at 11:15 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Thu, 8 Jan 2009, Geoff Russell wrote:
>
>> Dear gits,
>>
>> I have a series of commits:
>>
>> A---B---C---D---E---F
>>
>> I want to collapse B---C---D into one single commit. git rebase -i B
>> will allow me to do this, but I'm looking for a non-interactive
>> incantation.
>
> You set GIT_EDITOR to a script ;-)
This is plan B.
>
> Alternatively, something like this should work for you:
>
> $ git checkout A
> $ git read-tree -u -m D
> $ git commit -m "My message"
> $ git cherry-pick E
> $ git cherry-pick F
Plan B is looking good, because I'd generally like the commit message to be the
concatenation of the messages for B,C and D.
Many thanks.
Geoff.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 0:08 collapsing commits with rebase Geoff Russell
2009-01-08 0:45 ` Johannes Schindelin
@ 2009-01-08 2:11 ` Boyd Stephen Smith Jr.
2009-01-08 2:32 ` Miklos Vajna
2009-01-08 4:09 ` Sitaram Chamarty
2009-01-10 10:26 ` nadim khemir
2 siblings, 2 replies; 12+ messages in thread
From: Boyd Stephen Smith Jr. @ 2009-01-08 2:11 UTC (permalink / raw
To: geoffrey.russell; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 846 bytes --]
On Wednesday 2009 January 07 18:08:44 Geoff Russell wrote:
>I have a series of commits:
>
> A---B---C---D---E---F
Assuming you also have a ref (e.g. Foo) that points to F:
git checkout sha(B)
git merge -s sha(D)
git rebase --onto $(cat .git/HEAD) sha(E) Foo
should do what you want.
After the checkout:
A -> B [HEAD] -> C -> D -> E -> F [Foo]
(detached HEAD)
After the merge:
A -> B -> C -> D -> E -> F [Foo]
|
+--> [HEAD]
(detached HEAD)
After the rebase:
A -> B -> E' -> F' [Foo, HEAD]
|
+--> C -> D -> E -> F
(C, D, E, and F will be pruned at some point)
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 2:11 ` Boyd Stephen Smith Jr.
@ 2009-01-08 2:32 ` Miklos Vajna
2009-01-08 2:39 ` Boyd Stephen Smith Jr.
2009-01-08 4:09 ` Sitaram Chamarty
1 sibling, 1 reply; 12+ messages in thread
From: Miklos Vajna @ 2009-01-08 2:32 UTC (permalink / raw
To: Boyd Stephen Smith Jr.; +Cc: geoffrey.russell, git
[-- Attachment #1: Type: text/plain, Size: 266 bytes --]
On Wed, Jan 07, 2009 at 08:11:32PM -0600, "Boyd Stephen Smith Jr." <bss@iguanasuicide.net> wrote:
> git merge -s sha(D)
You probably mean --squash here, -s stands for --strategy - and I *hope*
you don't have git-sha(D) in your PATH, as a custom merge strategy. ;-)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 2:32 ` Miklos Vajna
@ 2009-01-08 2:39 ` Boyd Stephen Smith Jr.
2009-01-08 9:49 ` Geoff Russell
0 siblings, 1 reply; 12+ messages in thread
From: Boyd Stephen Smith Jr. @ 2009-01-08 2:39 UTC (permalink / raw
To: Miklos Vajna; +Cc: geoffrey.russell, git
[-- Attachment #1: Type: text/plain, Size: 598 bytes --]
On Wednesday 2009 January 07 20:32:24 Miklos Vajna wrote:
>On Wed, Jan 07, 2009 at 08:11:32PM -0600, "Boyd Stephen Smith Jr."
<bss@iguanasuicide.net> wrote:
>> git merge -s sha(D)
>
>You probably mean --squash here, -s stands for --strategy - and I *hope*
>you don't have git-sha(D) in your PATH, as a custom merge strategy. ;-)
Oops. Yes. My mistake.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 2:11 ` Boyd Stephen Smith Jr.
2009-01-08 2:32 ` Miklos Vajna
@ 2009-01-08 4:09 ` Sitaram Chamarty
2009-01-08 4:23 ` Boyd Stephen Smith Jr.
1 sibling, 1 reply; 12+ messages in thread
From: Sitaram Chamarty @ 2009-01-08 4:09 UTC (permalink / raw
To: git
On 2009-01-08, Boyd Stephen Smith Jr. <bss@iguanasuicide.net> wrote:
>> A---B---C---D---E---F
> Assuming you also have a ref (e.g. Foo) that points to F:
> git checkout sha(B)
> git merge -s sha(D)
I think you now need to do a commit (assuming you meant
"--squash"). Squash will not commit, and your rebase below
(if it runs at all -- I suspect it will refuse to run) will
hard reset to B, the current HEAD. IOW
> After the merge:
> A -> B -> C -> D -> E -> F [Foo]
> |
> +--> [HEAD]
is not true. You have C+D in the index, not in the tree.
> git rebase --onto $(cat .git/HEAD) sha(E) Foo
Also I think you have an off-by-one error here; you need
sha(D) in that rebase command, not sha(E).
As your rebase command stands, you will lose commit E
completely; neither the merge nor the rebase will pick it
up.
[Haven't tested, but I *think* I understand rebase well
enough now to say so...]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 4:09 ` Sitaram Chamarty
@ 2009-01-08 4:23 ` Boyd Stephen Smith Jr.
0 siblings, 0 replies; 12+ messages in thread
From: Boyd Stephen Smith Jr. @ 2009-01-08 4:23 UTC (permalink / raw
To: Sitaram Chamarty; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 585 bytes --]
On Wednesday 2009 January 07 22:09:15 Sitaram Chamarty wrote:
>[Haven't tested, but I *think* I understand rebase well
>enough now to say so...]
Probably understand it better than me. I just haven't needed to use it for
this that much. This also might not be much better than setting GIT_PAGER to
a script, but it seems less fragile to me.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss@iguanasuicide.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/ \_/
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 2:39 ` Boyd Stephen Smith Jr.
@ 2009-01-08 9:49 ` Geoff Russell
0 siblings, 0 replies; 12+ messages in thread
From: Geoff Russell @ 2009-01-08 9:49 UTC (permalink / raw
To: Boyd Stephen Smith Jr.; +Cc: Miklos Vajna, git
On 1/8/09, Boyd Stephen Smith Jr. <bss@iguanasuicide.net> wrote:
> On Wednesday 2009 January 07 20:32:24 Miklos Vajna wrote:
> >On Wed, Jan 07, 2009 at 08:11:32PM -0600, "Boyd Stephen Smith Jr."
> <bss@iguanasuicide.net> wrote:
> >> git merge -s sha(D)
> >
> >You probably mean --squash here, -s stands for --strategy - and I *hope*
> >you don't have git-sha(D) in your PATH, as a custom merge strategy. ;-)
>
Many thanks, now I have plenty of ways to think about!
Cheers,
Geoff.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 1:59 ` Geoff Russell
@ 2009-01-08 11:07 ` Johannes Schindelin
2009-01-10 10:34 ` Geoff Russell
0 siblings, 1 reply; 12+ messages in thread
From: Johannes Schindelin @ 2009-01-08 11:07 UTC (permalink / raw
To: Geoff Russell; +Cc: git
Hi,
On Thu, 8 Jan 2009, Geoff Russell wrote:
> On Thu, Jan 8, 2009 at 11:15 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>
> > Alternatively, something like this should work for you:
> >
> > $ git checkout A
> > $ git read-tree -u -m D
> > $ git commit -m "My message"
> > $ git cherry-pick E
> > $ git cherry-pick F
>
> Plan B is looking good, because I'd generally like the commit message to
> be the concatenation of the messages for B,C and D.
Replace the commit call by this:
$ for commit in B C D
do
git cat-file commit $commit | sed '1,/^$/d'
# possibly add an empty line between the commit messages,
# git commit will strip away empty lines at the end.
done |
git commit -F -
Hth,
Dscho
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 0:08 collapsing commits with rebase Geoff Russell
2009-01-08 0:45 ` Johannes Schindelin
2009-01-08 2:11 ` Boyd Stephen Smith Jr.
@ 2009-01-10 10:26 ` nadim khemir
2 siblings, 0 replies; 12+ messages in thread
From: nadim khemir @ 2009-01-10 10:26 UTC (permalink / raw
To: git
On Thursday 08 January 2009 01.08.44 Geoff Russell wrote:
> Dear gits,
>
> I have a series of commits:
>
> A---B---C---D---E---F
>
> I want to collapse B---C---D into one single commit. git rebase -i B will
> allow me to do this, but I'm looking for a non-interactive incantation.
Hi Geoff, Could you please share with use the final (tested) solution? I'd be
interrested to see how you did implement plan B if you did.
Cheers, Nadim.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: collapsing commits with rebase
2009-01-08 11:07 ` Johannes Schindelin
@ 2009-01-10 10:34 ` Geoff Russell
0 siblings, 0 replies; 12+ messages in thread
From: Geoff Russell @ 2009-01-10 10:34 UTC (permalink / raw
To: Johannes Schindelin; +Cc: git
On 1/8/09, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Thu, 8 Jan 2009, Geoff Russell wrote:
>
> > On Thu, Jan 8, 2009 at 11:15 AM, Johannes Schindelin
> > <Johannes.Schindelin@gmx.de> wrote:
> >
>
> > > Alternatively, something like this should work for you:
> > >
> > > $ git checkout A
> > > $ git read-tree -u -m D
> > > $ git commit -m "My message"
> > > $ git cherry-pick E
> > > $ git cherry-pick F
> >
> > Plan B is looking good, because I'd generally like the commit message to
> > be the concatenation of the messages for B,C and D.
>
>
> Replace the commit call by this:
>
> $ for commit in B C D
> do
> git cat-file commit $commit | sed '1,/^$/d'
> # possibly add an empty line between the commit messages,
> # git commit will strip away empty lines at the end.
> done |
> git commit -F -
>
> Hth,
> Dscho
That makes sense, many thanks.
Cheers,
Geoff.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-01-10 10:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-08 0:08 collapsing commits with rebase Geoff Russell
2009-01-08 0:45 ` Johannes Schindelin
2009-01-08 1:59 ` Geoff Russell
2009-01-08 11:07 ` Johannes Schindelin
2009-01-10 10:34 ` Geoff Russell
2009-01-08 2:11 ` Boyd Stephen Smith Jr.
2009-01-08 2:32 ` Miklos Vajna
2009-01-08 2:39 ` Boyd Stephen Smith Jr.
2009-01-08 9:49 ` Geoff Russell
2009-01-08 4:09 ` Sitaram Chamarty
2009-01-08 4:23 ` Boyd Stephen Smith Jr.
2009-01-10 10:26 ` nadim khemir
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).