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

could `git merge --no-ff origin/master` be made more useful?

From
Ddemerphq <demerphq@gmail.com>
Date
May 14, 2018, 22:08 UTC
Message-ID
<CANgJU+VFCY0LNRLMSGtD7ScpcLaPFMzUOyw6Bjgk6q=Kx9DvCg@mail.gmail.com>
The first time I tried to use --no-ff I tried to do something like this:
  git checkout master
  git commit -a -m'whatever'
  git commit -a -m'whatever2'
  git merge --no-ff origin/master

and was disappointed when "it didn't work" and git told me there was nothing to do as the branch was up to date. (Which I found a bit confusing.)

I realize now my expectations were incorrect, and that the argument to merge needs to resolve to a commit that is ahead of the current commit, and in the above sequence it is the other way around. So to do what I want I can do:

  git checkout master
  git checkout -b topic
  git commit -a -m'whatever'
  git commit -a -m'whatever2'
  git checkout master
  git merge --no-ff topic
and iiuir this works because 'master' would be behind 'topic' in this case.

But I have a few questions, 1) is there is an argument to feed to git merge to make the first recipe work like the second? And 2) is this asymmetry necessary with --no-ff?

More specifically would something horrible break if --no-ff origin/trunk detected that the current branch was ahead of the named branch and "swapped" the implicit order of the two so that the first recipe could behave like the second?

Anyway, even if the above makes no sense, would it be hard to make the message provided by git merge in the first recipe a bit more suggestive of what is going on? For instance if it had said "Cannot --no-ff merge, origin/master is behind master" it would have been much more clear what was going on.

Yves
-- 
perl -Mre=debug -e "/just|another|perl|hacker/"
Next: Ævar Arnfjörð Bjarmason
Message 1 of 3 in “could `git merge --no-ff origin/master` be made more useful?”
  1. demerphqMay 14, 2018
  2. Ævar Arnfjörð BjarmasonMay 14, 2018
  3. demerphqMay 15, 2018

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.