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

Re: git merge and merge message

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 11, 2007, 20:19 UTC
Message-ID
<Pine.LNX.4.64.0703111309410.9690@woody.linux-foundation.org>
In-Reply-To
<200703111815.l2BIFHbq010315@localhost.localdomain>
On Sun, 11 Mar 2007, Xavier Maillard wrote:
Show 12 quoted lines
>    On Sun, Mar 11, 2007 at 04:05:04PM +0100, Xavier Maillard wrote:
>    > The merge is correct but there is not merge message when I do a
>    > git log.
> 
>    Have you done any work on the master branch since you branched the topic
>    branch off from it?  If not, the merge is just a "fast forward"--no
>    merge commit is created, and instead the head of the master branch is
>    just updated to point at the same commit as the head of the topic
>    branch.
> 
> No I did not touch master before. It could explain that behaviour
> then :)
Indeed.

The "don't merge, just fast-forward" is the right thing to do for working together. However, I can well imagine that if you actually work with branches not as "distributed development", but *just* as "topic branches", then having the "useless" merge (with the parents actually being parents of each other) migth actually be nice from a documentation standpoint.

I'm torn on this. I really dislike anything but fast-forward, because I have a strong suspicion that it will cause "alpha male" behaviour (where maintainers use the "useless merge" as a way to mark their territory), which I think is actually really bad form.

At the same time, I think that the kind of behaviour that Xavier is talking about, where you actually end up having feature branches for your own project, and then using

	git merge -m "Merge feature Xyz" xyz-branch

is potentially a really good way of making it clear that the code along the branch you merged did Xyz.

My other rule in life is that a tool should not *force* a certain policy (although encouraging good behaviour by making that the *easy* thing to do is a good idea), so I think that it would probably be ok to add a flag to "git merge" to say "force a merge commit", which would disable the fast-forward behaviour.

(And if you don't support it for "git pull", maybe that's enough of a disincentive that you won't see the "maintainer marking his territory by peeing in the snow" behaviour).

Comments? Do people think it would be a good idea to do
	git merge --no-fast-forward -m "Merge feature Xyz" xyz-branch
as an option?
			Linus
Previous: Xavier MaillardNext: Avi Kivity
Message 5 of 15 in “git merge and merge message”
  1. Xavier MaillardMar 11, 2007
  2. J. Bruce FieldsMar 11, 2007
  3. git-merge: warn when -m provided on a fast forwardJ. Bruce Fields, Mar 11, 2007
  4. Xavier MaillardMar 11, 2007
  5. Linus TorvaldsMar 11, 2007
  6. Avi KivityMar 11, 2007
  7. Linus TorvaldsMar 11, 2007
  8. Avi KivityMar 12, 2007
  9. Johannes SchindelinMar 11, 2007
  10. Junio C HamanoMar 12, 2007
  11. Avi KivityMar 12, 2007
  12. Junio C HamanoMar 11, 2007
  13. [RFC] git log --first-parentJunio C Hamano, Mar 13, 2007
  14. Jeff KingMar 13, 2007
  15. Martin LanghoffMar 12, 2007

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.