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@xxxxxxxxx> 1659010359 +0200 committer Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 1659010359 +0200 data 9 Add file M 100644 :1 file.txt commit refs/heads/master mark :3 author Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 1659010437 +0200 committer Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 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@xxxxxxxxx> 1659010369 +0200 committer Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 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@xxxxxxxxx> 1659010359 +0200 committer Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> 1659010644 +0200 data 9 Add file from :4 M 100644 :5 file.txt