From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "Laďa Tesařík" <lada.tesarik@olc.cz>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Lost file after git merge
Date: Thu, 28 Jul 2022 14:17:51 +0200 [thread overview]
Message-ID: <220728.865yjhl8wk.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <HE1PR0501MB24096E2FBDB66318A2FDADAAF8969@HE1PR0501MB2409.eurprd05.prod.outlook.com>
On Thu, Jul 28 2022, Laďa Tesařík wrote:
> 1. I added a file called 'new_file' to a master branch.
> 2. Then I created branch feature/2 and deleted the file in master
> 3. Then I deleted the file in branch feature/2 as well.
> 4. I created 'new_file' on branch feature/2 again.
> 5. I merged feature/2 into master, merge introduced no changes, file 'new_file' is not present in master.
>
> This could cause problems to our team in the future, fortunately we noticed it this time.
> Please, does anybody have any explanation for this behavior?
>
> Or is anybody aware of any Git or Source option that changes this behaviour?
>
> Thank you very much,
>
> Lada Tesarik
>
> P. S.
> In the picture the steps were done with git revert command, but result is the same if I delete file manually and perform git commit.
> Tested with git versions 2.26 and 2.37
Those who know "merge" better will chime in, but I believe this is known
behavior, and you can see why if your "topic" branch doesn't
(re)introduce the file as it was on master, but adds a small change to
it.
I quickly experimented with this (with the fast-export stream at the
end). If you had a "hello" as the content on "master" and introduced
"hello2" on the topic you'd get:
$ git merge topic
CONFLICT (modify/delete): file.txt deleted in HEAD and modified in topic. Version topic of file.txt left in tree.
Automatic merge failed; fix conflicts and then commit the result.
So others will know better, but I vaguely recall this having to do with
this being the same in your version (not the below hello2 version, but
if you s/hello2/hello/):
git rev-parse $(git merge-base topic master):
git rev-parse topic:
I.e. the topic is the TREESAME as its divergence point with "master",
which IIRC is a shortcut the merge takes when deciding what changes to
keep, and whether they conflict.
--
blob
mark :1
data 6
hello
reset refs/heads/master
commit refs/heads/master
mark :2
author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010359 +0200
committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010359 +0200
data 9
Add file
M 100644 :1 file.txt
commit refs/heads/master
mark :3
author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010437 +0200
committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010437 +0200
data 81
Revert "Add file"
This reverts commit 75aa73c55b19219d47dfc7ec3883c88466678718.
from :2
D file.txt
commit refs/heads/topic
mark :4
author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010369 +0200
committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010369 +0200
data 81
Revert "Add file"
This reverts commit 75aa73c55b19219d47dfc7ec3883c88466678718.
from :2
D file.txt
blob
mark :5
data 7
hello2
commit refs/heads/topic
mark :6
author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010359 +0200
committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1659010644 +0200
data 9
Add file
from :4
M 100644 :5 file.txt
next prev parent reply other threads:[~2022-07-28 12:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 8:23 Lost file after git merge Laďa Tesařík
2022-07-28 12:17 ` Ævar Arnfjörð Bjarmason [this message]
2022-07-28 17:11 ` Junio C Hamano
2022-07-29 20:23 ` René Scharfe
2022-07-29 22:04 ` Junio C Hamano
2022-07-30 2:16 ` Elijah Newren
2022-07-30 14:44 ` René Scharfe
2022-07-31 1:45 ` Elijah Newren
2022-07-28 21:23 ` brian m. carlson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=220728.865yjhl8wk.gmgdl@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=lada.tesarik@olc.cz \
/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.
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 NNTP newsgroup(s).