Home > Software engineering >  Beginner: How to merge 2 README.md files (branch merge)
Beginner: How to merge 2 README.md files (branch merge)

Time:10-27

I have a problem where I need to merge 2 branches, both containing a README.md file.problem If I try to merge the 2 branches with the readme to a 3rd branch, ofc the first one gets through without a problem. If I try the 2nd branch ofc it gives me a content conflict, because the 2nd readme would delete the email out of the 1st one. Now we were given a website which should have helped fix that with a mergetool, but if we try to change something via the mergetool the 2 lines seem to be "stuck" together, meaning if I change a line with local it changes both, same with remote. I'm pretty new to git etc. (like a few hours max) and I have no idea how to find a solution, so any help would be great^^

Trying to merge 2 README files, content conflict. Mergetool didn't work like i thought it would.

CodePudding user response:

Note: this answer got too long so I've split it into two parts.

Part 1 (part 2 here)

You have encountered a basic stumbling block for those who try to use Git without a tutorial, or with a bad tutorial (of which there are, unfortunately, many). Your mistake here is thinking that "merge", in Git, involves two versions of some file. This is not the case! Merging in Git is on a commit basis and involves three versions of each file.

Before we can get into merging, we have to start with commits. Without the proper base,1 merging won't make any sense. So let's jump into that first. Note that you may want to read this twice before you tackle your merge.


1There's a pun here that will fly right over your head if you're not already familiar with the ideas behind merging.

  • Related