git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Bryan Turner <bturner@atlassian.com>
To: Git Users <git@vger.kernel.org>
Subject: "Losing" MERGE_HEAD
Date: Thu, 30 May 2019 21:16:56 -0700	[thread overview]
Message-ID: <CAGyf7-EgiWtt0xu9nfYdhafZ6D70nSxbNYAguFrN8OWRqWmzGQ@mail.gmail.com> (raw)

I was looking through the commit history in a repository I work in and
I found a place where someone had created a merge, but somewhere
between "git merge" and "git commit" the fact that it was a merge was
"lost". Instead they ended up with a really big commit that applied
all the changes from the merged-in branch.

A really easy way to reproduce this is:
git merge master #Assume this has conflicts, or use --no-commit
git checkout -b some-new-branch

When the checkout runs, MERGE_HEAD et al are deleted without any sort
of warning, but the uncommitted changes are not lost. If a user then
runs "git commit", and doesn't notice that there's no helpful "It
looks like you may be committing a merge", they'll create a new,
non-merge commit that essentially reapplies all the changes they
merged in.

I'm pretty familiar with Git and I make this mistake at least a few
times a year. So far I've always caught it during the commit, though.
Unfortunately, in this case, the bad "merge" wasn't noticed before it
made its way to master, so now it's there for good.

I'm not sure what there is to do about this. It's clear it's a
long-standing behavior. One approach might be to introduce a warning
when changing branches deletes MERGE_*. A different one might be to
fail to change branches without something like --force. I'm not sure
either is _better_ than the current behavior, but they're certainly
_clearer_. That said, perhaps this behavior is something someone
relies on.

Best regards,
Bryan Turner

             reply	other threads:[~2019-05-31  4:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31  4:16 Bryan Turner [this message]
2019-05-31  6:03 ` "Losing" MERGE_HEAD Elijah Newren

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=CAGyf7-EgiWtt0xu9nfYdhafZ6D70nSxbNYAguFrN8OWRqWmzGQ@mail.gmail.com \
    --to=bturner@atlassian.com \
    --cc=git@vger.kernel.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).