git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Andre Ulrich <andre.ulrich@smail.fh-koeln.de>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: fast forward merge overwriting my code
Date: Sun, 23 May 2021 23:58:03 +0000	[thread overview]
Message-ID: <YKrsC9CaG/KDvDBi@camp.crustytoothpaste.net> (raw)
In-Reply-To: <4c1c3dbc-7a89-02db-3883-b7eea644cd83@kdbg.org>

[-- Attachment #1: Type: text/plain, Size: 2565 bytes --]

On 2021-05-23 at 09:48:55, Johannes Sixt wrote:
> [resending, as I forgot to include git@vger]
> 
> Am 22.05.21 um 17:48 schrieb Andre Ulrich:
> > Let's say I have a .txt file on my master branch. I used
> > 
> > git add .
> > 
> > and
> > 
> > git commit -m "blabla"
> > 
> > so everything is staged and in the history. Now I check out a new branch
> > 
> > git checkout -b testing
> > 
> > and edit the .txt file. I add some new lines at the end, but I also
> > change some of the already existing lines. Then again I add and commit
> > everything. 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.
> > Just imagine this was working code, and changing some of the first lines
> > breaks everything in the following lines.
> > I think I have found out what is the problem: git considers this a fast
> > forward merge (since there were no commits on master between the
> > creation and the merging of the test branch).

Yes.  However, if Git did an actual merge, the result would be the same.
In a three-way merge, if one side changes, and the other does not, the
change is adopted.  A fast-forward merge just avoids the merge commit.

> > But this is annoying. I want to be able to choose, what changes I want
> > to keep, when I do the merge (just as in case of a 3way merge, when you
> > can call a graphical merge tool to decide what lines to keep).
> 
> But in a 3-way merge, you only get to choose which changes you take if
> there is a conflict. If, in your example, you had committed a change to
> a different file on master before the merge, you would get a
> non-fast-forward (3-way) merge, and still no opportunity to choose which
> changes you take because there would be no conflict.
> 
> And why do you think we need a general warning "when you merge, your
> code on master will be altered"? Why would I want to make a merge into
> master if not to change the code on master?

I suspect Andre has a goal here or a specific use case that we're not
understanding.  If we got some more explanation about what's going on,
we could probably offer a more useful response addressing that specific
use case or goal.  It might not be a use case we support, but at least
we could address it directly.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2021-05-23 23:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-22 15:48 fast forward merge overwriting my code Andre Ulrich
2021-05-22 17:12 ` Philip Oakley
2021-05-23 15:01   ` Junio C Hamano
2021-05-24  9:50     ` Philip Oakley
2021-05-23  9:48 ` Johannes Sixt
2021-05-23 23:58   ` brian m. carlson [this message]
2021-05-24  6:13     ` Andre Ulrich
2021-05-24 11:13       ` Bagas Sanjaya
2021-05-24 13:16       ` Philip Oakley
2021-05-24 15:06         ` Andre Ulrich
2021-05-24 18:48           ` Philip Oakley
2021-05-25 15:14             ` Philip Oakley
2021-05-30  5:31             ` David Aguilar
2021-05-30 11:00               ` Philip Oakley
2021-05-24 17:47       ` Igor Djordjevic
2021-05-26  2:53       ` Felipe Contreras
2021-05-26 11:06         ` Philip Oakley
2021-05-26 18:33           ` Felipe Contreras
2021-05-26 20:35             ` Philip Oakley
2021-05-26 23:34               ` Felipe Contreras
2021-05-27 12:05                 ` Philip Oakley
2021-05-27 14:00                   ` Felipe Contreras
2021-05-27 15:12                     ` Philip Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKrsC9CaG/KDvDBi@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=andre.ulrich@smail.fh-koeln.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).