0

I understand that a merge conflict arises when there are "competing" commits. In the situation where there is only one repo branch, and there are two contributors, both with write access, I suppose the merge conflict gets realized when the second commit tries to get pushed "over" the first one that involved a common file line.

How do we avoid this situation? Because my collaborator and I are rarely editing the same file, I have suggested that he just

git pull origin master 

before he starts working on anything. However, he has reported this error:

error: You have not concluded your merge (MERGE_HEAD exists)

I ask because most explanations of merge conflicts involve appeals to branching and pull requests, and it might not be necessary to mention these to get an explanation.

Taylor
  • 1,393
  • 2
  • 16
  • 40

1 Answers1

0

According to github, Merge conflicts happen when you merge branches that have competing commits, and Git needs your help to decide which changes to incorporate in the final merge.

Git can often resolve differences between branches and merge them automatically. Usually, the changes are on different lines, or even in different files, which makes the merge simple for computers to understand. However, sometimes there are competing changes that Git can't resolve without your help. Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file.

In your condition, a single repo branch and two or more contributors have to push their commits. In our startup also, we also have same approach for fast iteration. Here approach is like this -

  1. Make sure you both have clean branch to start.
  2. Whenever some have to push its commit, first stash their changes if present.
  3. Then do git pull --rebase this uses rebase merging strategy. ( this step will make sure unnecessary conflict not arise, simply doing git pull will pull the changes and merge with rebase pull and merge happen.
  4. Then push there changes with git push.

No more conflicts when some one push commit before other person.

abby37
  • 583
  • 4
  • 16