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

Re: Trouble testing out a patch on a branch new scratch git.git repository

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2009, 04:58 UTC
Message-ID
<7vmycww6if.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<e38bce640902081859o47462a58s59c120209fabb0@mail.gmail.com>
Brent Goodrick <bgoodr@gmail.com> writes:
Show 7 quoted lines
> What I really want to do is simply replace the last two commits on the
> branch with one commit, so that when I make my patch it will be just
> the full set of changes and not a lot of noise. Is there a way to do
> that? (note: I did try the git merge --squash command but it just
> showed me the usage, as I was on my bg/no-progress branch).  Note that
> I know that I would not be able to do this once some of my changes had
> merged upstream.

Suppose you have this topology. You forked and built 2 commits, while the upstream advanced its tip (or not).

                 1--2 your commits (master)
                /
	---o---o---o upstream (origin)
1. Using "rebase -i"
    ... on your "master"
    $ git rebase -i origin
    ... will give you an insn sheet for interactive rebase to edit.
    ... you will see something like:
	pick xxxxxx title of commit 1
       	pick yyyyyy title of commit 2
    ... edit the second "pick" to "squash", save and exit the editor.
    ... You are telling it to "first cherry-pick my 1, and then squash my
    ... 2 on top of it.
    ... it will do as it is told, and will give you another editor, with
    ... messages from both commits in it.  Edit to formulate a log message
    ... suitable for the combined commit, save and exit the editor.
   You will end up with:
	---o---o---o---X
   where rightmost 'o' is still origin, X is your two commits squashed
   into one.
2. Using "mrege -s squash"
    ... on your "master"
    $ git merge --squash origin
    ... this will stop without creating a commit.  Then you would
    $ git commit
    ... and the editor will give you the log message from all the
    ... commits on the branch you just merged.  Come up with a single
    ... log message to describe all, save and exit the editor.
   You will end up with:
	---o---o---o---X
   where rightmost 'o' is still origin, X is your two commits squashed
   into one.
Previous: Brent GoodrickNext: Brent Goodrick
Message 6 of 9 in “Trouble testing out a patch on a branch new scratch git.git repository”
  1. Brent GoodrickFeb 8, 2009
  2. Junio C HamanoFeb 8, 2009
  3. Brent GoodrickFeb 9, 2009
  4. Boyd Stephen Smith Jr.Feb 9, 2009
  5. Brent GoodrickFeb 9, 2009
  6. Junio C HamanoFeb 9, 2009
  7. Brent GoodrickFeb 9, 2009
  8. Boyd Stephen Smith Jr.Feb 9, 2009
  9. Sitaram ChamartyFeb 10, 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.