* *Non*-interactive squash a range ?
@ 2010-07-03 13:38 David
2010-07-05 6:27 ` Johannes Sixt
2010-07-05 7:00 ` Daniele Segato
0 siblings, 2 replies; 3+ messages in thread
From: David @ 2010-07-03 13:38 UTC (permalink / raw)
To: git
Thanks for the awesome git. I have a basic question. I am subscribed
to this list.
Having successfully used rebase -i to squash, I wonder about some
method to *non*-interactively squash a sequence of intermediate
commits. On a local experimental branch.
Lets say the starting point is this branch named "uglybranch" with HEAD=J
E---F---G---H---I---J <uglybranch>
where commit G added a previously untracked file.
My desired result is this:
------------------K <cleanbranch>
/
E---F---G---H---I---J <uglybranch>
where K and J are identical worktrees.
I've used rebase -i as follows:
$ git checkout uglybranch
$ git checkout -b cleanbranch
$ git rebase -i E
# used interactive editor to squash all F..J onto E to produce K, on
cleanbranch only, uglybranch is not changed.
This gives exactly the result I want, in particular the file added at
G is preserved, but the drawback is that the method is needlessly
interactive. I want a foolproof non-interactive method that achieves
the same result. Namely squashing *all* the commits in the range F..J
I tried this which seems to work:
$ git checkout uglybranch
$ git checkout -b cleanbranch
$ git reset --mixed E # worktree same as uglybranch
$ git add . # adds any untracked files
$ git commit -a # -a detects any removed files
So I'm thinking of using that method in a script. Have I overlooked
anything? Is there a better way?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: *Non*-interactive squash a range ?
2010-07-03 13:38 *Non*-interactive squash a range ? David
@ 2010-07-05 6:27 ` Johannes Sixt
2010-07-05 7:00 ` Daniele Segato
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2010-07-05 6:27 UTC (permalink / raw)
To: David; +Cc: git
Am 7/3/2010 15:38, schrieb David:
> I tried this which seems to work:
> $ git checkout uglybranch
> $ git checkout -b cleanbranch
> $ git reset --mixed E # worktree same as uglybranch
> $ git add . # adds any untracked files
> $ git commit -a # -a detects any removed files
>
> So I'm thinking of using that method in a script. Have I overlooked
> anything? Is there a better way?
Use 'reset --soft' instead of 'reset --mixed' followed by 'add .'.
-- Hannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: *Non*-interactive squash a range ?
2010-07-03 13:38 *Non*-interactive squash a range ? David
2010-07-05 6:27 ` Johannes Sixt
@ 2010-07-05 7:00 ` Daniele Segato
1 sibling, 0 replies; 3+ messages in thread
From: Daniele Segato @ 2010-07-05 7:00 UTC (permalink / raw)
To: David; +Cc: git
On Sat, Jul 3, 2010 at 3:38 PM, David <bouncingcats@gmail.com> wrote:
> Having successfully used rebase -i to squash, I wonder about some
> method to *non*-interactively squash a sequence of intermediate
> commits. On a local experimental branch.
[...]
> My desired result is this:
>
> ------------------K <cleanbranch>
> /
> E---F---G---H---I---J <uglybranch>
>
> where K and J are identical worktrees.
why don't you:
git checkout -b cleanbranch E~
git merge --squash J
regards,
Daniele Segato
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-05 7:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-03 13:38 *Non*-interactive squash a range ? David
2010-07-05 6:27 ` Johannes Sixt
2010-07-05 7:00 ` Daniele Segato
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).