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

git merge --squash isn't "marked as a merge"??

From
PLPeter Valdemar Mørch (Lists) <4ux6as402@sneakemail.com>
Date
Jul 29, 2008, 07:49 UTC
Message-ID
<488ECB89.5060801@sneakemail.com>
Newbie alert:

I have a feature branch where I have N tiny commits with sloppy/private commit messages. Being able to have private commits was the main reason I'm using git (as a frontend to svn).

Today the feature is in a "good" state, and I want to merge it into a main branch, showing a single commit with a well phrased message for all the world to see. So I:

$ git checkout master $ git merge --squash feature $ git commit -F wellphrased.msg

Now I was expecting that: $ git merge feature would do nothing (I already did a merge!). But it pulls in all the sloppy commits and messages from "feature"!

Of course now I could continue with a new branch made like this: $ git checkout -b feature2 master and continue working privately on feature2 again. Then I'll end up with feature..feature47 before I'm done. Each with its own segment of my private history. A real mess.

Can I continue on feature somehow so I privately can "git log" and see all my messy commits (both before and after the "git merge --squash") and then regularly "git merge" and/or "git merge --squash" back and forth between "feature" and "master" as I deem appropriate?

I'm guessing that if the --squash *did* put in a "merge arrow" (setting a "parent" of the commit to the head of feature) thereby allowing merge to not do anything, then git log would also follow feature's sloppy history too. They go together as a pair. Is that right? Testing this:

git help merge says about --squash:
> Produce the working tree and index state as if a real merge happened,
> 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.

So I tried "git merge --squash feature", then set up .git/MERGE_HEAD to the same contents as .git/refs/heads/feature and then "git commit". This produced the same result as "git merge" without --squash including all the sloppy messages.

SO: It seems to me I cannot continuously merge "feature" to "master" in 
chunks with "--squash" as I would like. Is that right? Is my desire 
fundamentally misguided, and is there A Better Way?
Peter
-- 
Peter Valdemar Mørch
http://www.morch.com
Next: Junio C Hamano
Message 1 of 2 in “git merge --squash isn't "marked as a merge"??”
  1. Peter Valdemar Mørch (Lists)Jul 29, 2008
  2. Junio C HamanoJul 29, 2008

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.