From: Howard Miller <howard@e-learndesign.co.uk>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Any way to "flatten" a series of changes in git
Date: Fri, 23 Oct 2009 06:36:10 +0100 [thread overview]
Message-ID: <26ae428a0910222236l58bc64b7l12c4cff09b086dac@mail.gmail.com> (raw)
In-Reply-To: <200910222357.15189.jnareb@gmail.com>
2009/10/22 Jakub Narebski <jnareb@gmail.com>:
> On Thu, 22 Oct 2009, Howard Miller wrote:
>
>> > You can use either "git merge --squash" or "git rebase --interactive"
>> > (changing 'pick' to 'squash').
>> >
>>
>> Actually thinking some more.... I don't understand something about
>> this. I don't actually want to merge or rebase with anything. I just
>> want to say "make those commits a series of commits on a branch into
>> just one commit with a new message". I seriously suspect I'm missing
>> the point somewhere but what has that got to do with merging or
>> rebasing?
>
> Actually using "git merge --squash" is a bit different from using
> "git rebase --interactive".
>
>
> 1. "git merge --squash"
>
> From documentation:
>
> --squash::
> Produce the working tree and index state as if a real
> merge happened (except for the merge information),
> but do not actually make a commit or
> move the `HEAD`, nor record `$GIT_DIR/MERGE_HEAD` to
> cause the next `git commit` command to create a merge
> commit. This allows you to create a single commit on
> top of the current branch whose effect is the same as
> merging another branch (or more in case of an octopus).
>
> This means for example if you did your changes on a separate
> topic branch, and you want to merge your changes into 'master'
> branch, you would do
>
> $ git checkout master
> $ git merge side-branch
>
> which would result in the following history:
>
>
> ---*---*---*---*---*---*---*---M <-- master
> \ /
> \-.---.---.---.---.---.-/ <-- side-branch
>
>
> If you used '--squash' option to git-merge, because changes were
> made in throwaway topic branch, and as you said only final result
> matter, you would get:
>
> $ git checkout master
> $ git merge --squash side-branch
>
> ---*---*---*---*---*---*---*---M' <-- master
> \
> \-.---.---.---.---.---. <-- side-branch
>
>
> where commit M' has the same contents (the same tree) as commit M
> in previous example, but is not a merge commit.
>
> If you simply want to squash last say 5 commits into one, you can
> use "git merge --squash" for it in the following way:
>
> $ git reset --hard HEAD~5
> $ git merge --squash --no-ff HEAD@{1}
>
> which means basically: rewind to state 5 commits back, then merge
> in changes from before rewind, squashing them. The --no-ff is needed
> because otherwise it would be fast-forward and no commit would be
> created.
>
>
> 2. "git rebase --interactive"
>
> The interactive rebase is meant to edit commits being rebased, but
> it can be used simply to edit commits. It includes 'squash' command
> that can be used to concatenate (squash) commits.
>
> So to squash last say 5 commits into one, you would use
>
> $ git rebase --interactive HEAD~5
>
> then edit provided list of commands and commits to read something like
> this:
>
> pick deadbee The oneline of this commit
> squash fa1afe1 The oneline of the next commit
> ...
> squash beedead The oneline of the that commit
>
> i.e. replace 'pick' command by 'squash' command.
>
> This is a very powerfull command, and can be used for example to turn
> series of say 5 commits into series of say 2 commits; not simply squashing
> to a single commit, but reducing number of commits (and presumably
> cleaning up those commits).
>
>
> HTH (hope that helps)
> --
> Jakub Narebski
> Poland
>
Hi Jakub,
Yes it helps a lot. What I *don't* care about (or want to do) is
actually do a merge or a rebase I just want to change history. Well,
that's what I thought I wanted. What I suppose I really want is the
full history for *me* and a second branch with the 'reduced' history
to push to my client. I suppose that's different yet again?
Howard
next prev parent reply other threads:[~2009-10-23 5:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-22 20:03 Any way to "flatten" a series of changes in git Howard Miller
2009-10-22 20:30 ` Bill Lear
2009-10-22 20:44 ` Bill Lear
2009-10-22 20:51 ` Jacob Helwig
2009-10-22 20:58 ` Howard Miller
2009-10-26 13:42 ` Daniele Segato
2009-10-22 20:59 ` Jakub Narebski
2009-10-22 21:11 ` Howard Miller
2009-10-22 21:24 ` Howard Miller
2009-10-22 21:57 ` Jakub Narebski
2009-10-23 5:36 ` Howard Miller [this message]
2009-10-23 5:40 ` Howard Miller
2009-10-23 5:48 ` Johannes Sixt
2009-10-23 6:16 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=26ae428a0910222236l58bc64b7l12c4cff09b086dac@mail.gmail.com \
--to=howard@e-learndesign.co.uk \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).