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

Re: fast forward merge overwriting my code

From
Philip Oakley <philipoakley@iee.email>
Date
May 24, 2021, 09:50 UTC
Message-ID
<f3f8927f-75af-c3bd-07af-5fd4b64987e9@iee.email>
In-Reply-To
<xmqqo8d1o5ni.fsf@gitster.g>
On 23/05/2021 16:01, Junio C Hamano wrote:
Show 22 quoted lines
> Philip Oakley <philipoakley@iee.email> writes:
>
>> On 22/05/2021 16:48, Andre Ulrich wrote:
>>> .... Then I use
>>>
>>> git checkout master
>>>
>>> and
>>>
>>> git merge testing
>>>
>>> I would expect git to tell me "hey, wait, you have changed some of the
>>> first lines in the .txt file. When you merge, your code on master will
>>> be altered". But git just merges everything in.
>> ...
>> maybe `git merge --no-ff testing` for use of a command line option
>>
>> or setup your .gitconfig e.g. `git config --global merge.ff no`,
>> but also `git config --global pull.ff yes` if you are using `git pull`
>> (=fetch + merge)
> I didn't get an impression that this has anything to do with
> fast-forwarding, though.  

Andre had (in the body of the text) explicitly said that it was the fast forward that was the problem for him.

I suspect he had a mental model / world view / weltanshauung that was more aligned to a swim lane model of branches (named lines of development) and that, possibly in a GUI, the loss two lanes was rather confusing.

Show 7 quoted lines
> The file in question has changes on the
> "testing" branch since it forked from "master", and the user is
> merging, i.e. the user _assumes_ that the tip of each branch suits
> his/her purpose better than the tip of the other branch, hence wants
> to take improvements on both branches incorporated into a single
> history--- which is the point of "merging" the testing branch into
> the master branch.  

In his description it's not always clear "also change some of the already existing lines" what happened elsewhere that could lead to the confusion. It will have been tricky for Andre, as someone new to git, to really know what was going on. We can't assume the new user knows what Git will do.

Show 22 quoted lines
> The result of merging might reveal that the tip
> of the other branch wasn't as great as s/he earlier thought, in
> which case s/he may want to undo the merge.  But if the result of
> merging better suites his/her purpose, it would be an improvement
> over where 'master' used to be (and it would also be an improvement
> over where 'testing' used to be), and the world makes a progress.
>
> In this particular case, the "master" side did not move since the
> two branches forked, so the merge was to take improvements made on
> "testing" into "master", and if the edit to the file in question
> made on "testing" were bogus, the merging operation of course will
> bring that breakage in, together with all the other changes.  Since
> the lack of any progress on the "master" side does not change this
> picture, I do not think fast-forwardness has anything to do with
> what Andre is complaining about.
>
> "git merge" cannot be expected to inspect the file and point out
> "no, the edit they made on the testing branch is totally bogus,
> don't merge it".  That is left for humans and tools other than Git
> (like test suite) may help them.
>
>

The changes to mental models that are needed to understand Git can take some time, especially for those who haven't grown up with it.

Philip
Previous: Junio C HamanoNext: Johannes Sixt
Message 4 of 23 in “fast forward merge overwriting my code”
  1. Andre UlrichMay 22, 2021
  2. Philip OakleyMay 22, 2021
  3. Junio C HamanoMay 23, 2021
  4. Philip OakleyMay 24, 2021
  5. Johannes SixtMay 23, 2021
  6. brian m. carlsonMay 23, 2021
  7. Andre UlrichMay 24, 2021
  8. Bagas SanjayaMay 24, 2021
  9. Philip OakleyMay 24, 2021
  10. Andre UlrichMay 24, 2021
  11. Philip OakleyMay 24, 2021
  12. Philip OakleyMay 25, 2021
  13. David AguilarMay 30, 2021
  14. Philip OakleyMay 30, 2021
  15. Igor DjordjevicMay 24, 2021
  16. Felipe ContrerasMay 26, 2021
  17. Philip OakleyMay 26, 2021
  18. Felipe ContrerasMay 26, 2021
  19. Philip OakleyMay 26, 2021
  20. Felipe ContrerasMay 26, 2021
  21. Philip OakleyMay 27, 2021
  22. Felipe ContrerasMay 27, 2021
  23. Philip OakleyMay 27, 2021

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.