Your Excellencies: I'm a new tech lead trying to figure out what caused a significant production issue. I want to know why the merge described below discards the content of a certain file from one branch and uses content from another branch, while saying that the file was "added by them". More importantly, I want to know how to prevent this in the future. DETAILS A dev wrote a feature across many files, including app/events/checkout_event.rb. Once merged and deployed, it was discovered that his changes to that file didn't make it to production... but many other changes from the same commit(s) did make it. After much research, we have isolated the issue to a specific ref -- a merge. It appears that, during the merge where both branches had changed that file, git decided to throw out changes to a from one branch and to use the other branch. I created three tags so my small brain didn't have to remember refs: * "working" (aa29d0f4) * other_parent (7f9ebfa5). * broken (ccbeb88) ---- jw@logopolis:/projects/unity/atlantis$ git show broken commit cbbeb883428a468e9c906c646becdf751ecff99a (broken) Merge: 7f9ebfa5 aa29d0f4 Author: Johnathon Wright <jw@xxxxxxxxxxxxxx> Date: Fri Oct 16 13:17:43 2020 -0400 merge ... ---- 'git show broken' doesn't show any changes to the file in question. Here, you can see that the files were different: ---- jw@logopolis:/projects/unity/atlantis$ git ls-tree working app/events/checkout_event.rb 100644 blob 077013dc52f03b336143b892c1468516cae29dce app/events/checkout_event.rb ---- and ---- jw@logopolis:/projects/unity/atlantis$ git ls-tree other_parent app/events/checkout_event.rb 100644 blob 21b3d4e9b5ac4903c2aadbed28ab5b60eb77e8ce app/events/checkout_event.rb ----- Then I tried to reproduce the merge: ---- jw@logopolis:/projects/unity/atlantis$ git checkout working HEAD is now at aa29d0f4 Track instances of price changing jw@logopolis:/projects/unity/atlantis$ git merge other_parent CONFLICT (rename/delete): spec/events/single_payment_event_spec.rb deleted in HEAD and renamed to spec/events/checkout_event_spec.rb in other_parent. Version other_parent of spec/events/checkout_event_spec.rb left in tree. Removing spec/commands/generate_ticket_and_send_command_spec.rb Auto-merging db/schema.rb CONFLICT (content): Merge conflict in db/schema.rb Auto-merging config/routes.rb Auto-merging app/models/user.rb CONFLICT (rename/delete): app/events/single_payment_event.rb deleted in HEAD and renamed to app/events/checkout_event.rb in other_parent. Version other_parent of app/events/checkout_event.rb left in tree. Auto-merging app/controllers/products_controller.rb Auto-merging app/controllers/priceline/price_points_controller.rb Automatic merge failed; fix conflicts and then commit the result. jw@logopolis:/projects/unity/atlantis$ git status HEAD detached at working You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge) Changes to be committed: new file: app/controllers/criteria_sets_controller.rb modified: app/controllers/priceline/price_points_controller.rb modified: app/controllers/products_controller.rb modified: app/events/search_hotels_event.rb modified: app/forms/search_hotels_form.rb modified: app/interfaces/priceline_api.rb modified: app/models/priceline/criteria_set.rb modified: app/models/user.rb modified: app/queries/hotels_filter_query.rb new file: app/views/products/waiting.html.erb modified: app/workers/generate_booking_ticket_worker.rb modified: app/workers/update_priceline_hotels_worker.rb modified: config/routes.rb new file: db/migrate/20201009200507_add_timestamps_to_pl_criteria_sets.rb new file: db/migrate/20201009235952_add_completion_flag_to_criteria_sets.rb deleted: spec/commands/generate_ticket_and_send_command_spec.rb modified: spec/forms/search_hotels_form_spec.rb Unmerged paths: (use "git add <file>..." to mark resolution) added by them: app/events/checkout_event.rb both modified: db/schema.rb added by them: spec/events/checkout_event_spec.rb ---- note that even though app/events/checkout_event.rb exists in both the "working" and "other_parent" branches, git here says "added by them". Note that "working" and "other_parent" both have parent nodes which rename the file in question from something else TO app/events/checkout_event.rb (same for the spec.) The two ancestors have different refs but the same datetime and commit message. This might also be of interest, or perhaps not. ---- jw@logopolis:/projects/unity/atlantis$ git diff working..broken -- app/events/checkout_event.rb | grep "^-" | wc -l 158 jw@logopolis:/projects/unity/atlantis$ git diff working..broken -- app/events/checkout_event.rb | grep "^+" | wc -l 51 ---- Final bit of information: ---- jw@logopolis:/projects/unity/atlantis$ git --version git version 2.17.1 ---- So, why does git say that this file was "added by them" instead of saying it had a conflict that needed merging? It has been suggested that this might have something to do with some team members using merge and others using rebase. Or possibly rebasing shared history. I don't know how to determine whether that's the case or whether that might have caused this. If so, I would appreciate seeing a set of instructions from a blank repo that cause this same thing to happen, so that I can help my team to understand the situation and how it can be avoided. If it is not related to rebasing and then merging, any help would be appreciated in diagnosing this issue. Thanks, jw