git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Any way to "flatten" a series of changes in git

From
Bill Lear <rael@zopyra.com>
Date
Oct 22, 2009, 20:44 UTC
Message-ID
<19168.50232.47935.864407@lisa.zopyra.com>
In-Reply-To
<19168.49405.775024.649626@lisa.zopyra.com>
On Thursday, October 22, 2009 at 15:30:53 (-0500) Bill Lear writes:
Show 10 quoted lines
>On Thursday, October 22, 2009 at 21:03:44 (+0100) Howard Miller writes:
>>Hello,
>>
>>I have a branch with a whole series of commits. I want to export this
>>work to be customer (to their svn repo if that has any bearing on it).
>>All the stuff in the history is irrelevant to my customer ("committing
>>now, going to bed" etc.) so I'd like to create a new branch that only
>>has one commit.. the end point with a new message. Is this possible?
>
>git rebase is your friend.
Someone correct me if I'm wrong.
% git branch
* master
% git checkout -b my_work_branch
% [work work work, commit, commit, commit]
% git rebase -i master
You'll then get an editor buffer that looks like this:

pick 16730c6 baz 0 pick 2a844e7 baz 1 pick d6e71dc baz 2 pick d1a6995 baz 3 pick 157e675 baz 4

# Rebase ef0a89e..157e675 onto ef0a89e # # Commands: # p, pick = use commit # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. #

Edit this to keep what you need: pick 16730c6 baz 0 squash 2a844e7 baz 1 squash d6e71dc baz 2 squash d1a6995 baz 3 squash 157e675 baz 4

then exit the editor. It'll pop you in another editor session to type in a commit message for these, just type in what you need and exit and you'll have the new commit with all the olds ones squashed into it.

Bill
Previous: Bill LearNext: Jacob Helwig
Message 3 of 14 in “Any way to "flatten" a series of changes in git”
  1. Howard MillerOct 22, 2009
  2. Bill LearOct 22, 2009
  3. Bill LearOct 22, 2009
  4. Jacob HelwigOct 22, 2009
  5. Howard MillerOct 22, 2009
  6. Daniele SegatoOct 26, 2009
  7. Jakub NarebskiOct 22, 2009
  8. Howard MillerOct 22, 2009
  9. Howard MillerOct 22, 2009
  10. Jakub NarebskiOct 22, 2009
  11. Howard MillerOct 23, 2009
  12. Howard MillerOct 23, 2009
  13. Johannes SixtOct 23, 2009
  14. Junio C HamanoOct 23, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.